[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[d-i] Yet Another bug with pre-sprintf malloc:ing



I found Yet Another bug with "pre-sprintf" malloc:ing in anna (in
retriever.c, get_packages), a patch is attached.

This got me thinking that we could avoid these kind of bugs if we had
some sort of decent string lib. I think the glib string functions are
pretty neat and my suggestion is to rip out the ones we need and put in
libd-i, perhaps under the "namespace" di_str_. Specificially,
g_strdup_sprintf would solve exactly these kind of problems for us.

Since Debian uses text files a lot, there's a lot of string juggling,
and that's no fun to do in C unless you've got decent tools...


Regards,
Martin
Index: retriever.c
===================================================================
RCS file: /cvs/debian-boot/debian-installer/anna/retriever.c,v
retrieving revision 1.11
diff -u -r1.11 retriever.c
--- retriever.c	25 Aug 2002 20:14:09 -0000	1.11
+++ retriever.c	26 Aug 2002 10:51:36 -0000
@@ -47,7 +47,8 @@
         suite = suites[currsuite];
         while (suite != NULL) {
           char *command=malloc(strlen(retriever) + 10 + 
-                               sizeof(tmp_packages) + 1);
+                               sizeof(tmp_packages) + 1 +
+                               strlen(suite) + 1);
 
                 unlink(tmp_packages);
                 sprintf(command, "%s Packages %s %s", retriever, tmp_packages, 

Attachment: signature.asc
Description: Detta =?ISO-8859-1?Q?=E4r?= en digitalt signerad meddelandedel


Reply to: