com php-src: fix more places with subtle negative zend_long to size_t cast: ext/standard/string.c
| From: | Anatol Belski | Date: | Mon, 29 Jun 2015 10:15:21 +0000 |
| Subject: | com php-src: fix more places with subtle negative zend_long to size_t cast: ext/standard/string.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-87618@lists.php.net to get a copy of this message | ||
Commit: c783645b99f35da3735977a05c9b7d0da372ce6b
Author: Anatol Belski <ab@php.net> Mon, 29 Jun 2015 11:35:36 +0200
Parents: c2ac0304a9699dfa41d87bdfcdd93585003eb8d3
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c783645b99f35da3735977a05c9b7d0da372ce6b
Log:
fix more places with subtle negative zend_long to size_t cast
Changed paths:
M ext/standard/string.c
Diff:
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 0a5e8be..1ce301e 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -2563,9 +2563,10 @@ PHP_FUNCTION(substr_replace)
f = zval_get_long(tmp_from);
if (f < 0) {
- f = orig_str->len + f;
- if (f < 0) {
+ if (-f > orig_str->len) {
f = 0;
+ } else {
+ f = orig_str->len + f;
}
} else if (f > orig_str->len) {
f = orig_str->len;
@@ -2577,9 +2578,10 @@ PHP_FUNCTION(substr_replace)
} else {
f = Z_LVAL_P(from);
if (f < 0) {
- f = orig_str->len + f;
- if (f < 0) {
+ if (-f > orig_str->len) {
f = 0;
+ } else {
+ f = orig_str->len + f;
}
} else if (f > orig_str->len) {
f = orig_str->len;