1--TEST-- 2Bug #40754 (Overflow checks inside string functions) 3--FILE-- 4<?php 5 6$v = 2147483647; 7 8var_dump(substr("abcde", 1, $v)); 9var_dump(substr_replace("abcde", "x", $v, $v)); 10var_dump(strspn("abcde", "abc", $v, $v)); 11var_dump(strcspn("abcde", "abc", $v, $v)); 12 13try { 14 var_dump(substr_count("abcde", "abc", $v, $v)); 15} catch (ValueError $exception) { 16 echo $exception->getMessage() . "\n"; 17} 18 19try { 20 substr_compare("abcde", "abc", $v, $v); 21} catch (ValueError $exception) { 22 echo $exception->getMessage() . "\n"; 23} 24 25try { 26 stripos("abcde", "abc", $v); 27} catch (ValueError $exception) { 28 echo $exception->getMessage() . "\n"; 29} 30 31try { 32 substr_count("abcde", "abc", $v, 1); 33} catch (ValueError $exception) { 34 echo $exception->getMessage() . "\n"; 35} 36 37try { 38 substr_count("abcde", "abc", 1, $v); 39} catch (ValueError $exception) { 40 echo $exception->getMessage() . "\n"; 41} 42 43try { 44 strpos("abcde", "abc", $v); 45} catch (ValueError $exception) { 46 echo $exception->getMessage() . "\n"; 47} 48 49try { 50 stripos("abcde", "abc", $v); 51} catch (ValueError $exception) { 52 echo $exception->getMessage() . "\n"; 53} 54 55try { 56 strrpos("abcde", "abc", $v); 57} catch (ValueError $exception) { 58 echo $exception->getMessage() . "\n"; 59} 60 61try { 62 strripos("abcde", "abc", $v); 63} catch (ValueError $exception) { 64 echo $exception->getMessage() . "\n"; 65} 66 67try { 68 strripos("abcde", "abc", $v); 69} catch (ValueError $exception) { 70 echo $exception->getMessage() . "\n"; 71} 72 73var_dump(strncmp("abcde", "abc", $v)); 74var_dump(chunk_split("abcde", $v, "abc")); 75var_dump(substr("abcde", $v, $v)); 76 77?> 78--EXPECT-- 79string(4) "bcde" 80string(6) "abcdex" 81int(0) 82int(0) 83substr_count(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 84substr_compare(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 85stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 86substr_count(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 87substr_count(): Argument #4 ($length) must be contained in argument #1 ($haystack) 88strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 89stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 90strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 91strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 92strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 93int(1) 94string(8) "abcdeabc" 95string(0) "" 96