Subject: Re: libc.112 vs perl/spamassassin problems
To: None <current-users@netbsd.org>
From: Takahiro Kambe <taca@back-street.net>
List: current-users
Date: 02/24/2004 23:44:58
In message <20040224.023159.101875170.taca@back-street.net>
	on Tue, 24 Feb 2004 02:31:59 +0900 (JST),
	Takahiro Kambe <taca@back-street.net> wrote:
> And one more:
And still sometimes dumps core.

This patch seems to solve the problem.

-- 
Takahiro Kambe <taca@back-street.net>


Index: net/getprotoent_r.c
===================================================================
RCS file: /usr/local/share/cvs/src/lib/libc/net/getprotoent_r.c,v
retrieving revision 1.1.1.1.2.2
diff -u -r1.1.1.1.2.2 getprotoent_r.c
--- net/getprotoent_r.c	23 Feb 2004 16:10:46 -0000	1.1.1.1.2.2
+++ net/getprotoent_r.c	24 Feb 2004 14:29:16 -0000
@@ -109,7 +109,8 @@
 			*p++ = '\0';
 		pr->p_proto = atoi(cp);
 		if (pd->aliases == NULL) {
-			pd->aliases = malloc(pd->maxaliases = 10);
+			pd->maxaliases = 10;
+			pd->aliases = malloc(pd->maxaliases * sizeof(char **));
 			if (pd->aliases == NULL) {
 				oerrno = errno;
 				endprotoent_r(pd);
@@ -127,7 +128,7 @@
 				}
 				if (i == pd->maxaliases - 2) {
 					pd->maxaliases *= 2;
-					q = realloc(q, pd->maxaliases);
+					q = realloc(q, pd->maxaliases * sizeof(char **));
 					if (q == NULL) {
 						oerrno = errno;
 						endprotoent_r(pd);
Index: net/getservent_r.c
===================================================================
RCS file: /usr/local/share/cvs/src/lib/libc/net/getservent_r.c,v
retrieving revision 1.1.1.1.2.2
diff -u -r1.1.1.1.2.2 getservent_r.c
--- net/getservent_r.c	23 Feb 2004 16:10:46 -0000	1.1.1.1.2.2
+++ net/getservent_r.c	24 Feb 2004 14:29:40 -0000
@@ -111,7 +111,8 @@
 		sp->s_port = htons((u_short)atoi(p));
 		sp->s_proto = cp;
 		if (sd->aliases == NULL) {
-			sd->aliases = malloc(sd->maxaliases = 10);
+			sd->maxaliases = 10;
+			sd->aliases = malloc(sd->maxaliases * sizeof(char **));
 			if (sd->aliases == NULL) {
 				oerrno = errno;
 				endservent_r(sd);
@@ -130,7 +131,7 @@
 			}
 			if (i == sd->maxaliases - 2) {
 				sd->maxaliases *= 2;
-				q = realloc(q, sd->maxaliases);
+				q = realloc(q, sd->maxaliases * sizeof(char **));
 				if (q == NULL) {
 					oerrno = errno;
 					endservent_r(sd);