4 files changed +27
-9
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,12 @@ PHP NEWS
23
23
. Fix undefined behaviour in phpdbg_load_module_or_extension(). (nielsdos)
24
24
. Fix NULL pointer dereference in phpdbg_create_conditional_breal(). (nielsdos)
25
25
26
+ - Posix:
27
+ . Fix memory leak in posix_ttyname() (girgias)
28
+
29
+ - Standard:
30
+ . Fix GH-10187 (Segfault in stripslashes() with arm64). (nielsdos)
31
+
26
32
05 Jan 2023, PHP 8.2.1
27
33
28
34
- Core:
Original file line number Diff line number Diff line change @@ -474,15 +474,15 @@ PHP_FUNCTION(posix_ttyname)
474
474
efree (p );
475
475
RETURN_FALSE ;
476
476
}
477
- RETURN_STRING (p );
477
+ RETVAL_STRING (p );
478
478
efree (p );
479
479
#else
480
480
if (NULL == (p = ttyname (fd ))) {
481
481
POSIX_G (last_error ) = errno ;
482
482
RETURN_FALSE ;
483
483
}
484
- #endif
485
484
RETURN_STRING (p );
485
+ #endif
486
486
}
487
487
/* }}} */
488
488
Original file line number Diff line number Diff line change @@ -3990,19 +3990,23 @@ static zend_always_inline char *php_stripslashes_impl(const char *str, char *out
3990
3990
quad_word q ;
3991
3991
vst1q_u8 (q .mem , vceqq_u8 (x , vdupq_n_u8 ('\\' )));
3992
3992
if (q .dw [0 ] | q .dw [1 ]) {
3993
- int i = 0 ;
3994
- for (; i < 16 ; i ++ ) {
3993
+ unsigned int i = 0 ;
3994
+ while ( i < 16 ) {
3995
3995
if (q .mem [i ] == 0 ) {
3996
3996
* out ++ = str [i ];
3997
+ i ++ ;
3997
3998
continue ;
3998
3999
}
3999
4000
4000
4001
i ++ ; /* skip the slash */
4001
- char s = str [i ];
4002
- if (s == '0' )
4003
- * out ++ = '\0' ;
4004
- else
4005
- * out ++ = s ; /* preserve the next character */
4002
+ if (i < len ) {
4003
+ char s = str [i ];
4004
+ if (s == '0' )
4005
+ * out ++ = '\0' ;
4006
+ else
4007
+ * out ++ = s ; /* preserve the next character */
4008
+ i ++ ;
4009
+ }
4006
4010
}
4007
4011
str += i ;
4008
4012
len -= i ;
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-10187 (Segfault in stripslashes() with arm64)
3
+ --FILE--
4
+ <?php
5
+ var_dump (stripslashes ("1234567890abcde \\" ));
6
+ ?>
7
+ --EXPECT--
8
+ string(15) "1234567890abcde"
0 commit comments