Skip to content

Fix GH-10187: Segfault in stripslashes() with arm64 #10188

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
18 changes: 11 additions & 7 deletions ext/standard/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -3988,19 +3988,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;
Expand Down
8 changes: 8 additions & 0 deletions ext/standard/tests/strings/gh10187.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--TEST--
GH-10187 (Segfault in stripslashes() with arm64)
--FILE--
<?php
var_dump(stripslashes("1234567890abcde\\"));
?>
--EXPECT--
string(15) "1234567890abcde"