]> granicus.if.org Git - php/commitdiff
MFB51: Fixed possible crash in apache_getenv()/apache_setenv() on invalid
authorIlia Alshanetsky <iliaa@php.net>
Mon, 2 Jan 2006 22:19:53 +0000 (22:19 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 2 Jan 2006 22:19:53 +0000 (22:19 +0000)
parameters.

sapi/apache2handler/php_functions.c

index f6a0cab4d3b954865f14868c4770d44e40d9dca6..0ff80b7d25f03d364b4adbee8f28b07b8705420d 100644 (file)
@@ -264,10 +264,13 @@ PHP_FUNCTION(apache_setenv)
        ctx = SG(server_context);
 
        r = ctx->r;
-       if (arg_count == 3 && Z_STRVAL_PP(walk_to_top)) {
-               while(r->prev) {
-                       r = r->prev;
-               }       
+       if (arg_count == 3) {
+               convert_to_boolean_ex(walk_to_top);
+               if (Z_LVAL_PP(walk_to_top)) {
+                       while(r->prev) {
+                               r = r->prev;
+                       }
+               }
        }
 
        convert_to_string_ex(variable);
@@ -300,10 +303,13 @@ PHP_FUNCTION(apache_getenv)
        ctx = SG(server_context);
 
        r = ctx->r;
-       if (arg_count == 2 && Z_STRVAL_PP(walk_to_top)) {
-               while(r->prev) {
-                       r = r->prev;
-               }       
+       if (arg_count == 2) {
+               convert_to_boolean_ex(walk_to_top);
+               if (Z_LVAL_PP(walk_to_top)) {
+                       while(r->prev) {
+                               r = r->prev;
+                       }
+               }
        }
 
        convert_to_string_ex(variable);