Merge branch 'PHP-8.1' into PHP-8.2

* PHP-8.1:
  Fix GH-10187: Segfault in stripslashes() with arm64
  Fix memory leak in posix_ttyname()
This commit is contained in:
George Peter Banyard 2022-12-30 16:42:06 +00:00
commit e6c9b176d4
4 changed files with 27 additions and 9 deletions

6
NEWS
View file

@ -23,6 +23,12 @@ PHP NEWS
. Fix undefined behaviour in phpdbg_load_module_or_extension(). (nielsdos)
. Fix NULL pointer dereference in phpdbg_create_conditional_breal(). (nielsdos)
- Posix:
. Fix memory leak in posix_ttyname() (girgias)
- Standard:
. Fix GH-10187 (Segfault in stripslashes() with arm64). (nielsdos)
05 Jan 2023, PHP 8.2.1
- Core:

View file

@ -474,15 +474,15 @@ PHP_FUNCTION(posix_ttyname)
efree(p);
RETURN_FALSE;
}
RETURN_STRING(p);
RETVAL_STRING(p);
efree(p);
#else
if (NULL == (p = ttyname(fd))) {
POSIX_G(last_error) = errno;
RETURN_FALSE;
}
#endif
RETURN_STRING(p);
#endif
}
/* }}} */

View file

@ -3990,19 +3990,23 @@ static zend_always_inline char *php_stripslashes_impl(const char *str, char *out
quad_word q;
vst1q_u8(q.mem, vceqq_u8(x, vdupq_n_u8('\\')));
if (q.dw[0] | q.dw[1]) {
int i = 0;
for (; i < 16; i++) {
unsigned int i = 0;
while (i < 16) {
if (q.mem[i] == 0) {
*out++ = str[i];
i++;
continue;
}
i++; /* skip the slash */
char s = str[i];
if (s == '0')
*out++ = '\0';
else
*out++ = s; /* preserve the next character */
if (i < len) {
char s = str[i];
if (s == '0')
*out++ = '\0';
else
*out++ = s; /* preserve the next character */
i++;
}
}
str += i;
len -= i;

View file

@ -0,0 +1,8 @@
--TEST--
GH-10187 (Segfault in stripslashes() with arm64)
--FILE--
<?php
var_dump(stripslashes("1234567890abcde\\"));
?>
--EXPECT--
string(15) "1234567890abcde"