ptr = emalloc(size);
size = GetEnvironmentVariableA(str, ptr, size);
- RETURN_STRING(ptr, 0);
+ if (size == 0) {
+ /* has been removed between the two calls */
+ efree(ptr);
+ RETURN_EMPTY_STRING();
+ } else {
+ RETURN_STRING(ptr, 0);
+ }
}
#else
/* system method returns a const */
PHP_FUNCTION(parse_ini_string)
{
char *string = NULL, *str = NULL;
- size_t str_len = 0;
+ int str_len = 0;
zend_bool process_sections = 0;
long scanner_mode = ZEND_INI_SCANNER_NORMAL;
zend_ini_parser_cb_t ini_parser_cb;
RETURN_FALSE;
}
+ if (INT_MAX - str_len < ZEND_MMAP_AHEAD) {
+ RETVAL_FALSE;
+ }
+
/* Set callback function */
if (process_sections) {
BG(active_ini_file_section) = NULL;