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));
+ bufsize += 1024;
+ newbuf = (char*) realloc(buf, sizeof(char) * (bufsize + 2));
if (newbuf == NULL) {
ini_recursion--;
close(fd);
return -1;
}
buf = newbuf;
- memset(buf + ((bufsize + 1) * sizeof(char)), 0, sizeof(char) * 1024);
- bufsize += 1024;
}
buf[n] = c;
if (n == 0) {
continue;
}
+ /* always append newline and null terminate */
buf[n++] = '\n';
+ buf[n] = '\0';
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) {
}
free(tmp);
}
- memset(buf, 0, sizeof(char) * (bufsize + 1));
}
free(buf);
ini_recursion--;
close(fd);
return ret;
-
}
/* }}} */