ports/167938: [PATCH] net/p5-IO-Interface: fix incorrect pointer usage
Xin LI
delphij at FreeBSD.org
Tue May 15 20:30:02 UTC 2012
>Number: 167938
>Category: ports
>Synopsis: [PATCH] net/p5-IO-Interface: fix incorrect pointer usage
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Tue May 15 20:30:01 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator: Xin LI
>Release: FreeBSD 9.0-STABLE i386
>Organization:
iXsystems, Inc.
>Environment:
System: FreeBSD freefall.freebsd.org 9.0-STABLE FreeBSD 9.0-STABLE #6 r235139: Tue May 8 21:19:03 UTC 2012 simon at freefall.freebsd.org:/usr/obj/usr/src/sys/FREEFALL i386
>Description:
The current p5-IO-Interface code does an incorrect pointer usage,
basically:
getifaddrs(&ifap);
while (1) {
(some handling)
ifap = ifap -> ifa_next; <-- 1)
}
freeifaddrs(ifap); <--
The freeifaddrs() will be passed with a potentionally different
pointer because of 1).
>How-To-Repeat:
Call the function on latest -CURRENT.
>Fix:
The proposed changeset saves the ifap pointer and call freeifaddrs()
with the saved one to avoid this problem.
--- p5-IO-Interface.diff begins here ---
Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/net/p5-IO-Interface/Makefile,v
retrieving revision 1.12
diff -u -p -r1.12 Makefile
--- Makefile 25 Jul 2011 01:07:02 -0000 1.12
+++ Makefile 15 May 2012 20:18:03 -0000
@@ -7,6 +7,7 @@
PORTNAME= IO-Interface
PORTVERSION= 1.06
+PORTREVISION= 1
CATEGORIES= net perl5
MASTER_SITES= CPAN
PKGNAMEPREFIX= p5-
Index: files/patch-Interface.xs
===================================================================
RCS file: files/patch-Interface.xs
diff -N files/patch-Interface.xs
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ files/patch-Interface.xs 15 May 2012 20:17:51 -0000
@@ -0,0 +1,27 @@
+--- ./Interface.xs.orig 2008-06-06 08:51:42.000000000 -0700
++++ ./Interface.xs 2012-05-15 13:16:22.856348098 -0700
+@@ -567,6 +567,7 @@
+ struct ifreq ifr;
+ #if (defined(USE_GETIFADDRS) && defined(HAVE_SOCKADDR_DL_STRUCT))
+ struct ifaddrs* ifap = NULL;
++ struct ifaddrs* saved_ifap = NULL;
+ struct sockaddr_dl* sdl;
+ sa_family_t family;
+ char *sdlname, *haddr, *s;
+@@ -581,6 +582,7 @@
+ #endif
+ #if (defined(USE_GETIFADDRS) && defined(HAVE_SOCKADDR_DL_STRUCT))
+ getifaddrs(&ifap);
++ saved_ifap = ifap;
+
+ while(1) {
+ if (ifap == NULL) break;
+@@ -595,7 +597,7 @@
+ }
+ ifap = ifap -> ifa_next;
+ }
+- freeifaddrs(ifap);
++ freeifaddrs(saved_ifap);
+
+ s = hwaddr;
+ s[0] = '\0';
--- p5-IO-Interface.diff ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list