summaryrefslogtreecommitdiff
path: root/sapi/cgi/cgi_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'sapi/cgi/cgi_main.c')
-rw-r--r--sapi/cgi/cgi_main.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index c58afaae33..8ee624ef89 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -405,6 +405,18 @@ static char *_sapi_cgibin_putenv(char *name, char *value TSRMLS_DC)
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 @@ static char *_sapi_cgibin_putenv(char *name, char *value TSRMLS_DC)
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);
}