com php-src: Allow unlimited line length in fpm config files: sapi/fpm/fpm/fpm_conf.c

From: Date: Mon, 28 Oct 2013 09:35:01 +0000
Subject: com php-src: Allow unlimited line length in fpm config files: sapi/fpm/fpm/fpm_conf.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-80631@lists.php.net to get a copy of this message
Commit: 9ad8e89d4f080626a92fc8817ab156c09b6b266a Author: Chris Wright <chrisw@networkm.co.uk> Mon, 21 Oct 2013 12:01:27 +0100 Parents: cb47396d4601656173cffadf86f6342bcba5e2b7 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9ad8e89d4f080626a92fc8817ab156c09b6b266a Log: Allow unlimited line length in fpm config files Fixes bug #65933 Bugs: https://bugs.php.net/65933 Changed paths: M sapi/fpm/fpm/fpm_conf.c Diff: diff --git a/sapi/fpm/fpm/fpm_conf.c b/sapi/fpm/fpm/fpm_conf.c index cd5fc34..743d4ff 100644 --- a/sapi/fpm/fpm/fpm_conf.c +++ b/sapi/fpm/fpm/fpm_conf.c @@ -1465,7 +1465,8 @@ static void fpm_conf_ini_parser(zval *arg1, zval *arg2, zval *arg3, int callback int fpm_conf_load_ini_file(char *filename TSRMLS_DC) /* {{{ */ { int error = 0; - char buf[1024+1]; + char *buf = NULL, *newbuf = NULL; + int bufsize = 0; int fd, n; int nb_read = 1; char c = '*'; @@ -1492,19 +1493,35 @@ int fpm_conf_load_ini_file(char *filename TSRMLS_DC) /* {{{ */ ini_lineno = 0; while (nb_read > 0) { int tmp; - memset(buf, 0, sizeof(char) * (1024 + 1)); - for (n = 0; n < 1024 && (nb_read = read(fd, &c, sizeof(char))) == sizeof(char) && c != '\n'; n++) { + ini_lineno++; + ini_filename = filename; + for (n = 0; (nb_read = read(fd, &c, sizeof(char))) == sizeof(char) && c != '\n'; n++) { + if (n == bufsize) { + newbuf = (char*) realloc(buf, sizeof(char) * (bufsize + 1024 + 1)); + if (newbuf == NULL) { + ini_recursion--; + close(fd); + free(buf); + return -1; + } + buf = newbuf; + memset(buf + ((bufsize + 1) * sizeof(char)), 0, sizeof(char) * 1024); + bufsize += 1024; + } + buf[n] = c; } + if (n == 0) { + continue; + } buf[n++] = '\n'; - ini_lineno++; - ini_filename = filename; tmp = zend_parse_ini_string(buf, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t)fpm_conf_ini_parser, &error TSRMLS_CC); ini_filename = filename; if (error || tmp == FAILURE) { if (ini_include) free(ini_include); ini_recursion--; close(fd); + free(buf); return -1; } if (ini_include) { @@ -1516,11 +1533,14 @@ int fpm_conf_load_ini_file(char *filename TSRMLS_DC) /* {{{ */ free(tmp); ini_recursion--; close(fd); + free(buf); return -1; } free(tmp); } + memset(buf, 0, sizeof(char) * (bufsize + 1)); } + free(buf); ini_recursion--; close(fd);

« previous php.cvs (#80631) next »