From: Jérôme Loyet Date: Tue, 30 Nov 2010 19:37:10 +0000 (+0000) Subject: - Fixed bug #53412 (segfault when using -y) X-Git-Tag: php-5.3.4RC2~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4c76006fe353f649ffe3a079e09a9e16413ca3d9;p=php - Fixed bug #53412 (segfault when using -y) --- diff --git a/NEWS b/NEWS index e33da9ecdf..06447cd5da 100644 --- a/NEWS +++ b/NEWS @@ -272,6 +272,7 @@ returns int(0)). (slugonamission at gmail dot com) - PHP-FPM SAPI: + . Fixed bug #53412 (segfault when using -y). (fat) . Fixed inconsistent backlog default value (-1) in FPM on many systems. (fat) . Fixed bug #52501 (libevent made FPM crashed when forking -- libevent has been removed). (fat) diff --git a/sapi/fpm/fpm/fpm.c b/sapi/fpm/fpm/fpm.c index 60e8e4ef3a..17a215c888 100644 --- a/sapi/fpm/fpm/fpm.c +++ b/sapi/fpm/fpm/fpm.c @@ -27,7 +27,9 @@ int fpm_init(int argc, char **argv, char *config, char *prefix, int test_conf) / { fpm_globals.argc = argc; fpm_globals.argv = argv; - fpm_globals.config = config; + if (config && *config) { + fpm_globals.config = strdup(config); + } fpm_globals.prefix = prefix; if (0 > fpm_php_init_main() || diff --git a/sapi/fpm/fpm/fpm_conf.c b/sapi/fpm/fpm/fpm_conf.c index 2389fc6759..f38227c2f2 100644 --- a/sapi/fpm/fpm/fpm_conf.c +++ b/sapi/fpm/fpm/fpm_conf.c @@ -794,7 +794,7 @@ static void fpm_conf_cleanup(int which, void *arg) /* {{{ */ free(fpm_global_config.error_log); fpm_global_config.pid_file = 0; fpm_global_config.error_log = 0; - efree(fpm_globals.config); + free(fpm_globals.config); } /* }}} */ @@ -1179,13 +1179,22 @@ int fpm_conf_init_main(int test_conf) /* {{{ */ } if (fpm_globals.config == NULL) { + char *tmp; if (fpm_globals.prefix == NULL) { - spprintf(&fpm_globals.config, 0, "%s/php-fpm.conf", PHP_SYSCONFDIR); + spprintf(&tmp, 0, "%s/php-fpm.conf", PHP_SYSCONFDIR); } else { - spprintf(&fpm_globals.config, 0, "%s/etc/php-fpm.conf", fpm_globals.prefix); + spprintf(&tmp, 0, "%s/etc/php-fpm.conf", fpm_globals.prefix); } + if (!tmp) { + zlog(ZLOG_SYSERROR, "spprintf() failed (tmp for fpm_globals.config)"); + return -1; + } + + fpm_globals.config = strdup(tmp); + efree(tmp); + if (!fpm_globals.config) { zlog(ZLOG_SYSERROR, "spprintf() failed (fpm_globals.config)"); return -1;