Skip to content

Fix uninitialized memory in parse_ini_string() #11092

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Zend/zend_ini_parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ static void zend_ini_init_string(zval *result)
} else {
ZVAL_EMPTY_STRING(result);
}
Z_EXTRA_P(result) = 0;
}
/* }}} */

Expand Down Expand Up @@ -307,6 +308,7 @@ static void normalize_value(zval *zv)
return;
}

ZEND_ASSERT(Z_EXTRA_P(zv) == 0 || Z_EXTRA_P(zv) == INI_ZVAL_IS_NUMBER);
if (Z_EXTRA_P(zv) == INI_ZVAL_IS_NUMBER && Z_TYPE_P(zv) == IS_STRING) {
zval number_rv;
if (convert_to_number(&number_rv, Z_STRVAL_P(zv), Z_STRLEN_P(zv)) == SUCCESS) {
Expand Down
2 changes: 2 additions & 0 deletions Zend/zend_ini_scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ ZEND_API zend_ini_scanner_globals ini_scanner_globals;
if (SCNG(scanner_mode) == ZEND_INI_SCANNER_TYPED && \
(YYSTATE == STATE(ST_VALUE) || YYSTATE == STATE(ST_RAW))) {\
zend_ini_copy_typed_value(ini_lval, type, str, len); \
Z_EXTRA_P(ini_lval) = 0; \
} else { \
zend_ini_copy_value(ini_lval, str, len); \
} \
Expand Down Expand Up @@ -598,6 +599,7 @@ end_raw_value_chars:
yyleng = YYCURSOR - SCNG(yy_text);

zend_ini_escape_string(ini_lval, yytext, yyleng, '"');
Z_EXTRA_P(ini_lval) = 0;
return TC_QUOTED_STRING;
}

Expand Down