Annotation of embedaddon/php/ext/standard/tests/strings/bug40754.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Bug #40754 (Overflow checks inside string functions)
! 3: --FILE--
! 4: <?php
! 5:
! 6: $v = 2147483647;
! 7:
! 8: var_dump(substr("abcde", 1, $v));
! 9: var_dump(substr_replace("abcde", "x", $v, $v));
! 10:
! 11: var_dump(strspn("abcde", "abc", $v, $v));
! 12: var_dump(strcspn("abcde", "abc", $v, $v));
! 13:
! 14: var_dump(substr_count("abcde", "abc", $v, $v));
! 15: var_dump(substr_compare("abcde", "abc", $v, $v));
! 16:
! 17: var_dump(stripos("abcde", "abc", $v));
! 18: var_dump(substr_count("abcde", "abc", $v, 1));
! 19: var_dump(substr_count("abcde", "abc", 1, $v));
! 20: var_dump(strpos("abcde", "abc", $v));
! 21: var_dump(stripos("abcde", "abc", $v));
! 22: var_dump(strrpos("abcde", "abc", $v));
! 23: var_dump(strripos("abcde", "abc", $v));
! 24: var_dump(strncmp("abcde", "abc", $v));
! 25: var_dump(chunk_split("abcde", $v, "abc"));
! 26: var_dump(substr("abcde", $v, $v));
! 27:
! 28: ?>
! 29: --EXPECTF--
! 30: %unicode|string%(4) "bcde"
! 31: %unicode|string%(6) "abcdex"
! 32: bool(false)
! 33: bool(false)
! 34:
! 35: Warning: substr_count(): Offset value 2147483647 exceeds string length in %s on line %d
! 36: bool(false)
! 37:
! 38: Warning: substr_compare(): The start position cannot exceed initial string length in %s on line %d
! 39: bool(false)
! 40:
! 41: Warning: stripos(): Offset not contained in string in %s on line %d
! 42: bool(false)
! 43:
! 44: Warning: substr_count(): Offset value 2147483647 exceeds string length in %s on line %d
! 45: bool(false)
! 46:
! 47: Warning: substr_count(): Length value 2147483647 exceeds string length in %s on line %d
! 48: bool(false)
! 49:
! 50: Warning: strpos(): Offset not contained in string in %s on line %d
! 51: bool(false)
! 52:
! 53: Warning: stripos(): Offset not contained in string in %s on line %d
! 54: bool(false)
! 55:
! 56: Warning: strrpos(): Offset is greater than the length of haystack string in %s on line %d
! 57: bool(false)
! 58:
! 59: Warning: strripos(): Offset is greater than the length of haystack string in %s on line %d
! 60: bool(false)
! 61: int(2)
! 62: string(8) "abcdeabc"
! 63: bool(false)
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>