nlopess         Sat Jun 17 11:08:05 2006 UTC

  Modified files:              (Branch: PHP_5_2)
    /php-src    configure.in 
    /php-src/sapi/cgi   cgi_main.c 
  Log:
  plug memory leak in sapi_putenv, by using setenv(), that doesnt need any 
malloc
  
http://cvs.php.net/viewcvs.cgi/php-src/configure.in?r1=1.579.2.52.2.1&r2=1.579.2.52.2.2&diff_format=u
Index: php-src/configure.in
diff -u php-src/configure.in:1.579.2.52.2.1 php-src/configure.in:1.579.2.52.2.2
--- php-src/configure.in:1.579.2.52.2.1 Sat May  6 21:58:03 2006
+++ php-src/configure.in        Sat Jun 17 11:08:05 2006
@@ -1,4 +1,4 @@
- ## $Id: configure.in,v 1.579.2.52.2.1 2006/05/06 21:58:03 iliaa Exp $ -*- 
autoconf -*-
+ ## $Id: configure.in,v 1.579.2.52.2.2 2006/06/17 11:08:05 nlopess Exp $ -*- 
autoconf -*-
 dnl ## Process this file with autoconf to produce a configure script.
 
 divert(1)
@@ -505,6 +505,7 @@
 setitimer \
 setlocale \
 localeconv \
+setenv \
 setpgid \
 setsockopt \
 setvbuf \
http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.5&r2=1.267.2.15.2.6&diff_format=u
Index: php-src/sapi/cgi/cgi_main.c
diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.5 
php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.6
--- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.5  Tue Jun 13 14:22:46 2006
+++ php-src/sapi/cgi/cgi_main.c Sat Jun 17 11:08:05 2006
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: cgi_main.c,v 1.267.2.15.2.5 2006/06/13 14:22:46 dmitry Exp $ */
+/* $Id: cgi_main.c,v 1.267.2.15.2.6 2006/06/17 11:08:05 nlopess Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -405,6 +405,18 @@
                return fcgi_putenv(request, name, name_len, value);
        }
 #endif
+#if HAVE_SETENV
+       if (value) {
+               setenv(name, value, 1);
+       }
+#endif
+#if HAVE_UNSETENV
+       if (!value) {
+               unsetenv(name);
+       }
+#endif
+
+#if !HAVE_SETENV || !HAVE_UNSETENV
        /*  if cgi, or fastcgi and not found in fcgi env
                check the regular environment 
                this leaks, but it's only cgi anyway, we'll fix
@@ -415,12 +427,19 @@
        if (buf == NULL) {
                return getenv(name);
        }
+#endif
+#if !HAVE_SETENV
        if (value) {
                len = snprintf(buf, len - 1, "%s=%s", name, value);
-       } else {
+               putenv(buf);
+       }
+#endif
+#if !HAVE_UNSETENV
+       if (!value) {
                len = snprintf(buf, len - 1, "%s=", name);
+               putenv(buf);
        }
-       putenv(buf);
+#endif
        return getenv(name);
 }
 


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to