Skip to content

Fix: sapi_getenv: value should be initialized and not used so #8786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions main/SAPI.c
Original file line number Diff line number Diff line change
Expand Up @@ -1007,29 +1007,30 @@ SAPI_API zend_stat_t *sapi_get_stat(void)

SAPI_API char *sapi_getenv(const char *name, size_t name_len)
{
char *value, *tmp;

if (!sapi_module.getenv) {
return NULL;
}
if (!strncasecmp(name, "HTTP_PROXY", name_len)) {
/* Ugly fix for HTTP_PROXY issue, see bug #72573 */
return NULL;
}
if (sapi_module.getenv) {
char *value, *tmp = sapi_module.getenv(name, name_len);
if (tmp) {
value = estrdup(tmp);
tmp = sapi_module.getenv(name, name_len);
if (!tmp) {
return NULL;
}
value = estrdup(tmp);
#ifdef PHP_WIN32
if (strlen(sapi_module.name) == sizeof("cgi-fcgi") - 1 && !strcmp(sapi_module.name, "cgi-fcgi")) {
/* XXX more modules to go, if needed. */
free(tmp);
}
if (strlen(sapi_module.name) == sizeof("cgi-fcgi") - 1 && !strcmp(sapi_module.name, "cgi-fcgi")) {
/* XXX more modules to go, if needed. */
free(tmp);
}
#endif
} else {
return NULL;
}
if (sapi_module.input_filter) {
sapi_module.input_filter(PARSE_STRING, name, &value, strlen(value), NULL);
}
return value;
if (sapi_module.input_filter) {
sapi_module.input_filter(PARSE_STRING, name, &value, strlen(value), NULL);
}
return NULL;
return value;
}

SAPI_API int sapi_get_fd(int *fd)
Expand Down