tags 398912 - moreinfo
tags 398912 + patch
thanks

On ons, 2007-08-15 at 18:23 +0200, Michal Pokrywka wrote:
> I just tested script attached to my bugreport and bug still exists.
> I reproduced it on two different machines: PIII with Linux 2.6.18-4-686
> and PIV with few xen domains with Linux 2.6.18-4-xen-686.

Hello again!

Thanks for testing and verifying the problem still exists.
With your hint I made some more efforts into reproducing it and managed
to do so on an older Pentium computer running Etch as well.

I've located the problem and created a patch that works for me. If you
could verify that it works for you as well that would be great.

The attached patch is against the Etch version of iproute, but seems to
apply against the Sid version as well (with some offset and fuzz, but
without failing).

Have a nice day!


-- 
Regards,
Andreas Henriksson
diff -urip iproute-20061002/include/utils.h iproute-20061002.fixed2/include/utils.h
--- iproute-20061002/include/utils.h	2006-10-02 22:13:34.000000000 +0200
+++ iproute-20061002.fixed2/include/utils.h	2007-08-16 00:51:58.000000000 +0200
@@ -132,7 +132,7 @@ int print_timestamp(FILE *fp);
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 
 extern int cmdlineno;
-extern size_t getcmdline(char **line, size_t *len, FILE *in);
+extern ssize_t getcmdline(char **line, size_t *len, FILE *in);
 extern int makeargs(char *line, char *argv[], int maxargs);
 
 #endif /* __UTILS_H__ */
diff -urip iproute-20061002/lib/utils.c iproute-20061002.fixed2/lib/utils.c
--- iproute-20061002/lib/utils.c	2006-10-02 22:13:34.000000000 +0200
+++ iproute-20061002.fixed2/lib/utils.c	2007-08-16 00:49:02.000000000 +0200
@@ -578,9 +578,9 @@ int print_timestamp(FILE *fp)
 int cmdlineno;
 
 /* Like glibc getline but handle continuation lines and comments */
-size_t getcmdline(char **linep, size_t *lenp, FILE *in)
+ssize_t getcmdline(char **linep, size_t *lenp, FILE *in)
 {
-	size_t cc;
+	ssize_t cc;
 	char *cp;
 		
 	if ((cc = getline(linep, lenp, in)) < 0)
@@ -608,9 +608,11 @@ size_t getcmdline(char **linep, size_t *
 		if (cp) 
 			*cp = '\0';
 
-		*linep = realloc(*linep, strlen(*linep) + strlen(line1) + 1);
+		*lenp = strlen(*linep) + strlen(line1) + 1;
+		*linep = realloc(*linep, *lenp);
 		if (!*linep) {
 			fprintf(stderr, "Out of memory\n");
+			*lenp = 0;
 			return -1;
 		}
 		cc += cc1 - 2;

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to