com php-src: Fix invalid free: sapi/cgi/cgi_main.c

From: Date: Sat, 13 Jan 2018 11:32:22 +0000
Subject: com php-src: Fix invalid free: sapi/cgi/cgi_main.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-100872@lists.php.net to get a copy of this message
Commit: 2503a27ae088cf349775fa6dbd95ee1d3d764c79 Author: Anatol Belski <ab@php.net> Sat, 13 Jan 2018 12:32:00 +0100 Parents: 8c07170ddbe28d8cc31e71f0ceb94fc4ac329657 Branches: PHP-7.1 PHP-7.2 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=2503a27ae088cf349775fa6dbd95ee1d3d764c79 Log: Fix invalid free Changed paths: M sapi/cgi/cgi_main.c Diff: diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index e0c0c7f..b0f1c1b 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -582,12 +582,20 @@ static char *sapi_fcgi_getenv(char *name, size_t name_len) fcgi_request *request = (fcgi_request*) SG(server_context); char *ret = fcgi_getenv(request, name, (int)name_len); +#ifndef PHP_WIN32 if (ret) return ret; /* if cgi, or fastcgi and not found in fcgi env check the regular environment */ -#ifndef PHP_WIN32 return getenv(name); #else + if (ret) { + /* The functions outside here don't know, where does it come + from. They'll need to free the returned memory as it's + not necessary from the fcgi env. */ + return strdup(ret); + } + /* if cgi, or fastcgi and not found in fcgi env + check the regular environment */ return cgi_getenv_win32(name, name_len); #endif }

« previous php.cvs (#100872) next »