@@ -1476,7 +1476,8 @@ static void fpm_conf_ini_parser(zval *arg1, zval *arg2, zval *arg3, int callback
1476
1476
int fpm_conf_load_ini_file (char * filename TSRMLS_DC ) /* {{{ */
1477
1477
{
1478
1478
int error = 0 ;
1479
- char buf [1024 + 1 ];
1479
+ char * buf = NULL , * newbuf = NULL ;
1480
+ int bufsize = 0 ;
1480
1481
int fd , n ;
1481
1482
int nb_read = 1 ;
1482
1483
char c = '*' ;
@@ -1503,19 +1504,35 @@ int fpm_conf_load_ini_file(char *filename TSRMLS_DC) /* {{{ */
1503
1504
ini_lineno = 0 ;
1504
1505
while (nb_read > 0 ) {
1505
1506
int tmp ;
1506
- memset (buf , 0 , sizeof (char ) * (1024 + 1 ));
1507
- for (n = 0 ; n < 1024 && (nb_read = read (fd , & c , sizeof (char ))) == sizeof (char ) && c != '\n' ; n ++ ) {
1507
+ ini_lineno ++ ;
1508
+ ini_filename = filename ;
1509
+ for (n = 0 ; (nb_read = read (fd , & c , sizeof (char ))) == sizeof (char ) && c != '\n' ; n ++ ) {
1510
+ if (n == bufsize ) {
1511
+ newbuf = (char * ) realloc (buf , sizeof (char ) * (bufsize + 1024 + 1 ));
1512
+ if (newbuf == NULL ) {
1513
+ ini_recursion -- ;
1514
+ close (fd );
1515
+ free (buf );
1516
+ return -1 ;
1517
+ }
1518
+ buf = newbuf ;
1519
+ memset (buf + ((bufsize + 1 ) * sizeof (char )), 0 , sizeof (char ) * 1024 );
1520
+ bufsize += 1024 ;
1521
+ }
1522
+
1508
1523
buf [n ] = c ;
1509
1524
}
1525
+ if (n == 0 ) {
1526
+ continue ;
1527
+ }
1510
1528
buf [n ++ ] = '\n' ;
1511
- ini_lineno ++ ;
1512
- ini_filename = filename ;
1513
1529
tmp = zend_parse_ini_string (buf , 1 , ZEND_INI_SCANNER_NORMAL , (zend_ini_parser_cb_t )fpm_conf_ini_parser , & error TSRMLS_CC );
1514
1530
ini_filename = filename ;
1515
1531
if (error || tmp == FAILURE ) {
1516
1532
if (ini_include ) free (ini_include );
1517
1533
ini_recursion -- ;
1518
1534
close (fd );
1535
+ free (buf );
1519
1536
return -1 ;
1520
1537
}
1521
1538
if (ini_include ) {
@@ -1527,11 +1544,14 @@ int fpm_conf_load_ini_file(char *filename TSRMLS_DC) /* {{{ */
1527
1544
free (tmp );
1528
1545
ini_recursion -- ;
1529
1546
close (fd );
1547
+ free (buf );
1530
1548
return -1 ;
1531
1549
}
1532
1550
free (tmp );
1533
1551
}
1552
+ memset (buf , 0 , sizeof (char ) * (bufsize + 1 ));
1534
1553
}
1554
+ free (buf );
1535
1555
1536
1556
ini_recursion -- ;
1537
1557
close (fd );
0 commit comments