tag 602832 patch
thanks

On Mon, Nov 08, 2010 at 06:14:19PM +0100, gregor herrmann wrote:
> severity 602832 grave
> retitle 602832 libsocket-getaddrinfo-perl: 0.16-1 segfaults on lenny and 
> squeeze
> fixed 602832 0.19-1
> thanks

Here's an isolated fix from upstream 0.18_001.

Looking at the code, I think squeeze would be better with the other
fixes in 0.19 but that's not my call.
-- 
Niko Tyni   nt...@debian.org
>From 2b0de3cec8d87d163ed18bb260d77d35eec4eff1 Mon Sep 17 00:00:00 2001
From: Niko Tyni <nt...@debian.org>
Date: Thu, 11 Nov 2010 12:53:28 +0200
Subject: [PATCH] Fix crash on missing arguments to getaddrinfo()

Isolated from upstream version 0.18_001.
---
 lib/Socket/GetAddrInfo.xs |    2 +-
 t/01getaddrinfo.t         |   10 +++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/lib/Socket/GetAddrInfo.xs b/lib/Socket/GetAddrInfo.xs
index f6c0864..a786f96 100644
--- a/lib/Socket/GetAddrInfo.xs
+++ b/lib/Socket/GetAddrInfo.xs
@@ -111,7 +111,7 @@ BOOT:
   setup_constants();
 
 void
-getaddrinfo(host=NULL, service=NULL, hints=NULL)
+getaddrinfo(host=&PL_sv_undef, service=&PL_sv_undef, hints=NULL)
     SV   *host
     SV   *service
     SV   *hints
diff --git a/t/01getaddrinfo.t b/t/01getaddrinfo.t
index 3899712..d75c68c 100644
--- a/t/01getaddrinfo.t
+++ b/t/01getaddrinfo.t
@@ -2,7 +2,7 @@
 
 use strict;
 
-use Test::More tests => 28;
+use Test::More tests => 30;
 use Test::Exception;
 
 use Socket::GetAddrInfo qw( :newapi getaddrinfo AI_NUMERICHOST );
@@ -186,3 +186,11 @@ dies_ok( sub { getaddrinfo( "127.0.0.1", "80", "hints" ) },
          'getaddrinfo() with string hints dies' );
 dies_ok( sub { getaddrinfo( "127.0.0.1", "80", [] ) },
          'getaddrinfo() with ARRAY hints dies' );
+
+# Ensure it doesn't segfault if args are missing
+
+( $err, @res ) = getaddrinfo();
+ok( defined $err, '$err defined for getaddrinfo()' );
+
+( $err, @res ) = getaddrinfo( "127.0.0.1" );
+ok( defined $err, '$err defined for getaddrinfo("127.0.0.1")' );
-- 
1.7.2.3

Reply via email to