From 627540cc0bb6a13c0789d54035777d7c2fc7b952 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Loyet?= Date: Mon, 18 Jul 2011 21:03:44 +0000 Subject: [PATCH] fix a segfault when passing an empty value to a ini parameter from the web server (php_(admin_)?value) --- sapi/fpm/fpm/fpm_main.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c index c7ad49e40f..c2db60f111 100644 --- a/sapi/fpm/fpm/fpm_main.c +++ b/sapi/fpm/fpm/fpm_main.c @@ -1430,22 +1430,28 @@ static void init_request_info(TSRMLS_D) static void fastcgi_ini_parser(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg TSRMLS_DC) /* {{{ */ { int *mode = (int *)arg; - char *key = Z_STRVAL_P(arg1); - char *value = Z_STRVAL_P(arg2); + char *key; + char *value = NULL; struct key_value_s kv; - if (!mode) return; + if (!mode || !arg1) return; if (callback_type != ZEND_INI_PARSER_ENTRY) { fprintf(stderr, "Passing INI directive through FastCGI: only classic entries are allowed\n"); return; } + key = Z_STRVAL_P(arg1); + if (!key || strlen(key) < 1) { fprintf(stderr, "Passing INI directive through FastCGI: empty key\n"); return; } + if (arg2) { + value = Z_STRVAL_P(arg2); + } + if (!value) { fprintf(stderr, "Passing INI directive through FastCGI: empty value for key '%s'\n", key); return; -- 2.40.0