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