From 4c76006fe353f649ffe3a079e09a9e16413ca3d9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Loyet?= Date: Tue, 30 Nov 2010 19:37:10 +0000 Subject: [PATCH] - Fixed bug #53412 (segfault when using -y) --- NEWS | 1 + sapi/fpm/fpm/fpm.c | 4 +++- sapi/fpm/fpm/fpm_conf.c | 15 ++++++++++++--- 3 files changed, 16 insertions(+), 4 deletions(-) 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; -- 2.40.0