summaryrefslogtreecommitdiff
path: root/ext/standard/string.c
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2007-03-08 00:47:04 +0000
committerStanislav Malyshev <stas@php.net>2007-03-08 00:47:04 +0000
commit79195bfe2ee2ee2a479c80788d72e7f617dbbb3c (patch)
tree460cbc4aa8a87057e88b4e21fd294db32be747f0 /ext/standard/string.c
parentaf1843f866a5681f5f58d77b55046d923f9b8a47 (diff)
downloadphp-git-79195bfe2ee2ee2a479c80788d72e7f617dbbb3c.tar.gz
clarify checks and error messages
Diffstat (limited to 'ext/standard/string.c')
-rw-r--r--ext/standard/string.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 4b39d4904b..91f27ee54c 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -4655,7 +4655,7 @@ PHP_FUNCTION(substr_count)
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length should be greater than 0.");
RETURN_FALSE;
}
- if ((p + Z_LVAL_PP(length)) <= p || (p + Z_LVAL_PP(length)) > endp) {
+ if (Z_LVAL_PP(length) > (Z_STRLEN_PP(haystack) - Z_LVAL_PP(offset))) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length value %ld exceeds string length.", Z_LVAL_PP(length));
RETURN_FALSE;
}
@@ -5076,11 +5076,16 @@ PHP_FUNCTION(substr_compare)
offset = (offset < 0) ? 0 : offset;
}
- if ((offset + len) > s1_len || (offset+len) < 0) {
+ if(offset > s1_len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The start position cannot exceed initial string length");
RETURN_FALSE;
}
+ if(len > s1_len - offset) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "The length cannot exceed initial string length");
+ RETURN_FALSE;
+ }
+
cmp_len = (uint) (len ? len : MAX(s2_len, (s1_len - offset)));
if (!cs) {