@@ -167,7 +167,7 @@ static zend_string *php_hex2bin(const unsigned char *old, const size_t oldlen)
167
167
int is_letter = ((unsigned int ) ((l - 'A' ) ^ (l - 'F' - 1 ))) >> (8 * sizeof (unsigned int ) - 1 );
168
168
unsigned char d ;
169
169
170
- /* basically (c >= '0' && c <= '9') || (l >= 'A' && l <= 'F') */
170
+ /* basically (c >= '0' && c <= '9') || (l >= 'A' && l <= 'F') */
171
171
if (EXPECTED ((((c ^ '0' ) - 10 ) >> (8 * sizeof (unsigned int ) - 1 )) | is_letter )) {
172
172
d = (l - 0x10 - 0x27 * is_letter ) << 4 ;
173
173
} else {
@@ -2412,7 +2412,11 @@ PHP_FUNCTION(substr)
2412
2412
}
2413
2413
}
2414
2414
2415
- if ((f + l ) > (zend_long )ZSTR_LEN (str )) {
2415
+ if (f > (zend_long )ZSTR_LEN (str )) {
2416
+ RETURN_FALSE ;
2417
+ }
2418
+
2419
+ if ((size_t )l > ZSTR_LEN (str ) - (size_t )f ) {
2416
2420
l = ZSTR_LEN (str ) - f ;
2417
2421
}
2418
2422
@@ -2889,7 +2893,7 @@ PHPAPI char *php_strtr(char *str, size_t len, char *str_from, char *str_to, size
2889
2893
for (i = 0 ; i < trlen ; i ++ ) {
2890
2894
xlat [(size_t )(unsigned char ) str_from [i ]] = str_to [i ];
2891
2895
}
2892
-
2896
+
2893
2897
for (i = 0 ; i < len ; i ++ ) {
2894
2898
str [i ] = xlat [(size_t )(unsigned char ) str [i ]];
2895
2899
}
@@ -3282,7 +3286,7 @@ static zend_string *php_str_to_str_i_ex(zend_string *haystack, char *lc_haystack
3282
3286
zend_string_release (lc_needle );
3283
3287
goto nothing_todo ;
3284
3288
}
3285
-
3289
+
3286
3290
if (str_len > ZSTR_LEN (lc_needle )) {
3287
3291
new_str = zend_string_safe_alloc (count , str_len - ZSTR_LEN (lc_needle ), ZSTR_LEN (haystack ), 0 );
3288
3292
} else {
@@ -3445,7 +3449,7 @@ PHP_FUNCTION(strtr)
3445
3449
ZVAL_LONG (& tmp , num_key );
3446
3450
convert_to_string (& tmp );
3447
3451
str_key = Z_STR (tmp );
3448
- }
3452
+ }
3449
3453
replace = zval_get_string (entry );
3450
3454
if (ZSTR_LEN (str_key ) < 1 ) {
3451
3455
RETVAL_STR_COPY (str );
@@ -4012,7 +4016,7 @@ static zend_long php_str_replace_in_subject(zval *search, zval *replace, zval *s
4012
4016
zend_string_release (lc_subject_str );
4013
4017
lc_subject_str = NULL ;
4014
4018
}
4015
- }
4019
+ }
4016
4020
}
4017
4021
4018
4022
zend_string_release (search_str );
0 commit comments