[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [BusyBox] [httpd] small bugfix for addEnv
From:       Rainer Weikusat <rainer.weikusat () sncag ! com>
Date:       2005-02-18 18:40:12
Message-ID: 87vf8p90fn.fsf () farside ! sncag ! com
[Download RAW message or body]

At least according to the Linux-manpage, the value of the pointer is
undefined if an error occurs during asprintf, so checking the return
value is probably a better idea.

Index: busybox//networking/httpd.c
===================================================================
RCS file: /data/repo/busybox/networking/httpd.c,v
retrieving revision 1.3
diff -u -r1.3 httpd.c
--- busybox//networking/httpd.c	17 Feb 2005 21:02:53 -0000	1.3
+++ busybox//networking/httpd.c	18 Feb 2005 18:17:40 -0000
@@ -809,15 +809,14 @@
 {
   char *s = NULL;
   const char *underline;
+  int rc;
 
   if (!value)
 	value = "";
   underline = *name_after_underline ? "_" : "";
-  asprintf(&s, "%s%s%s=%s", name_before_underline, underline,
-					name_after_underline, value);
-  if(s) {
-    putenv(s);
-  }
+  rc = asprintf(&s, "%s%s%s=%s", name_before_underline, underline,
+		name_after_underline, value);
+  if (rc != -1) putenv(s);
 }
 
 #if defined(CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV) || \
!defined(CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY)



_______________________________________________
busybox mailing list
busybox@mail.busybox.net
http://codepoet.org/mailman/listinfo/busybox


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic