svn: /php/php-src/ branches/PHP_5_3/ext/standard/string.c trunk/ext/standard/string.c
| From: | Ilia Alshanetsky | Date: | Fri, 06 Aug 2010 19:11:34 +0000 |
| Subject: | svn: /php/php-src/ branches/PHP_5_3/ext/standard/string.c trunk/ext/standard/string.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-63221@lists.php.net to get a copy of this message | ||
iliaa Fri, 06 Aug 2010 19:11:34 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=301936
Log:
Use correct order of operations. Second of many fixes for bug #52550
Bug: http://bugs.php.net/52550 (Analyzed) integer undefined
behaviors executed during "make test"
Changed paths:
U php/php-src/branches/PHP_5_3/ext/standard/string.c
U php/php-src/trunk/ext/standard/string.c
Modified: php/php-src/branches/PHP_5_3/ext/standard/string.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/string.c 2010-08-06 18:20:41 UTC (rev 301935)
+++ php/php-src/branches/PHP_5_3/ext/standard/string.c 2010-08-06 19:11:34 UTC (rev 301936)
@@ -1873,7 +1873,7 @@
p = haystack + offset;
e = haystack + haystack_len - needle_len;
} else {
- if (-offset > haystack_len || offset < -INT_MAX) {
+ if (offset < -INT_MAX || -offset > haystack_len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack
string");
RETURN_FALSE;
}
@@ -1951,7 +1951,7 @@
e = haystack + haystack_len - 1;
} else {
p = haystack;
- if (-offset > haystack_len || offset < -INT_MAX) {
+ if (offset < -INT_MAX || -offset > haystack_len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack
string");
RETURN_FALSE;
}
@@ -1983,7 +1983,7 @@
p = haystack_dup + offset;
e = haystack_dup + haystack_len - needle_len;
} else {
- if (-offset > haystack_len || offset < -INT_MAX) {
+ if (offset < -INT_MAX || -offset > haystack_len) {
efree(needle_dup);
efree(haystack_dup);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack
string");
Modified: php/php-src/trunk/ext/standard/string.c
===================================================================
--- php/php-src/trunk/ext/standard/string.c 2010-08-06 18:20:41 UTC (rev 301935)
+++ php/php-src/trunk/ext/standard/string.c 2010-08-06 19:11:34 UTC (rev 301936)
@@ -1873,7 +1873,7 @@
p = haystack + offset;
e = haystack + haystack_len - needle_len;
} else {
- if (-offset > haystack_len || offset < -INT_MAX) {
+ if (offset < -INT_MAX || -offset > haystack_len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack
string");
RETURN_FALSE;
}
@@ -1951,7 +1951,7 @@
e = haystack + haystack_len - 1;
} else {
p = haystack;
- if (-offset > haystack_len || offset < -INT_MAX) {
+ if (offset < -INT_MAX || -offset > haystack_len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack
string");
RETURN_FALSE;
}
@@ -1983,7 +1983,7 @@
p = haystack_dup + offset;
e = haystack_dup + haystack_len - needle_len;
} else {
- if (-offset > haystack_len || offset < -INT_MAX) {
+ if (offset < -INT_MAX || -offset > haystack_len) {
efree(needle_dup);
efree(haystack_dup);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack
string");