From 16c9af1c7dad2155a7175a0b50b84e6632a9c14f Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Tue, 29 May 2007 20:11:23 +0000 Subject: MFB --- ext/standard/dir.c | 2 +- ext/standard/mail.c | 4 +- ext/standard/tests/array/bug40709.phpt | 28 ++++++++++++ ext/standard/tests/strings/bug40432.phpt | 8 ++++ ext/standard/tests/strings/bug40704.phpt | 13 ++++++ ext/standard/tests/strings/bug40754.phpt | 63 ++++++++++++++++++++++++++ ext/standard/tests/strings/htmlentities18.phpt | 40 ++++++++++++++++ ext/standard/user_filters.c | 10 ++-- ext/wddx/tests/bug41283.phpt | 27 +++++++++++ 9 files changed, 188 insertions(+), 7 deletions(-) create mode 100644 ext/standard/tests/array/bug40709.phpt create mode 100644 ext/standard/tests/strings/bug40432.phpt create mode 100644 ext/standard/tests/strings/bug40704.phpt create mode 100644 ext/standard/tests/strings/bug40754.phpt create mode 100644 ext/standard/tests/strings/htmlentities18.phpt create mode 100644 ext/wddx/tests/bug41283.phpt (limited to 'ext') diff --git a/ext/standard/dir.c b/ext/standard/dir.c index e489072e2c..8b6fdc1329 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -449,7 +449,7 @@ PHP_FUNCTION(glob) /* we assume that any glob pattern will match files from one directory only so checking the dirname of the first match should be sufficient */ - strncpy(cwd, globbuf.gl_pathv[0], MAXPATHLEN); + strlcpy(cwd, globbuf.gl_pathv[0], MAXPATHLEN); if (php_check_open_basedir(cwd TSRMLS_CC)) { RETURN_FALSE; diff --git a/ext/standard/mail.c b/ext/standard/mail.c index d437e15c1c..70c1d323be 100644 --- a/ext/standard/mail.c +++ b/ext/standard/mail.c @@ -47,8 +47,8 @@ #define SKIP_LONG_HEADER_SEP(str, pos) \ if (str[pos] == '\r' && str[pos + 1] == '\n' && (str[pos + 2] == ' ' || str[pos + 2] == '\t')) { \ - pos += 3; \ - while (str[pos] == ' ' || str[pos] == '\t') { \ + pos += 2; \ + while (str[pos + 1] == ' ' || str[pos + 1] == '\t') { \ pos++; \ } \ continue; \ diff --git a/ext/standard/tests/array/bug40709.phpt b/ext/standard/tests/array/bug40709.phpt new file mode 100644 index 0000000000..6ab6bbd410 --- /dev/null +++ b/ext/standard/tests/array/bug40709.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #40709 (array_reduce() behaves strange with one item stored arrays) +--SKIPIF-- +--FILE-- + +--EXPECT-- +result for arr1: 1,2,3 +result for arr2: 1 +result for arr1: 1,2,3 +result for arr2: 1 +Done diff --git a/ext/standard/tests/strings/bug40432.phpt b/ext/standard/tests/strings/bug40432.phpt new file mode 100644 index 0000000000..6db2e94e58 --- /dev/null +++ b/ext/standard/tests/strings/bug40432.phpt @@ -0,0 +1,8 @@ +--TEST-- +Bug #40432 (strip_tags() fails with greater than in attribute) +--FILE-- + all">this') . "\n"; +?> +--EXPECT-- +this diff --git a/ext/standard/tests/strings/bug40704.phpt b/ext/standard/tests/strings/bug40704.phpt new file mode 100644 index 0000000000..82e91b5c87 --- /dev/null +++ b/ext/standard/tests/strings/bug40704.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #40704 (strip_tags() does not handle single quotes correctly) +--FILE-- +Bug ' Trigger Missing Text"; +var_dump(strip_tags($html)); + +echo "Done\n"; +?> +--EXPECT-- +string(26) "Bug ' Trigger Missing Text" +Done diff --git a/ext/standard/tests/strings/bug40754.phpt b/ext/standard/tests/strings/bug40754.phpt new file mode 100644 index 0000000000..23a459317b --- /dev/null +++ b/ext/standard/tests/strings/bug40754.phpt @@ -0,0 +1,63 @@ +--TEST-- +Bug #40754 (Overflow checks inside string functions) +--FILE-- + +--EXPECTF-- +string(4) "bcde" +bool(false) +bool(false) +bool(false) + +Warning: substr_count(): Offset value 2147483647 exceeds string length. in %s on line %d +bool(false) + +Warning: substr_compare(): The start position cannot exceed initial string length in %s on line %d +bool(false) + +Warning: stripos(): Offset not contained in string. in %s on line %d +bool(false) + +Warning: substr_count(): Offset value 2147483647 exceeds string length. in %s on line %d +bool(false) + +Warning: substr_count(): Length value 2147483647 exceeds string length. in %s on line %d +bool(false) + +Warning: strpos(): Offset not contained in string. in %s on line %d +bool(false) + +Warning: stripos(): Offset not contained in string. in %s on line %d +bool(false) + +Notice: strrpos(): Offset is greater than the length of haystack string in %s on line %d +bool(false) + +Notice: strripos(): Offset is greater than the length of haystack string in %s on line %d +bool(false) +int(2) +string(8) "abcdeabc" +bool(false) diff --git a/ext/standard/tests/strings/htmlentities18.phpt b/ext/standard/tests/strings/htmlentities18.phpt new file mode 100644 index 0000000000..ab3df05da8 --- /dev/null +++ b/ext/standard/tests/strings/htmlentities18.phpt @@ -0,0 +1,40 @@ +--TEST-- +htmlentities() / htmlspecialchars() "don't double encode" flag support +--FILE-- + +--EXPECT-- +string(3) "abc" +string(3) "abc" +string(13) "abc&sfdsa" +string(13) "abc&sfdsa" +string(33) "test+s & some more D" +string(33) "test+s & some more D" +string(24) "&; &amp &#a; &9;" +string(24) "&; &amp &#a; &9;" +string(32) "&kffjadfdhsjfhjasdhffasdfas;" +string(32) "&kffjadfdhsjfhjasdhffasdfas;" +string(16) "&#8787978789" +string(16) "&#8787978789" +string(5) "&" +string(5) "&" +string(15) "&&&" +string(15) "&&&" +string(17) "&ab&&" +string(17) "&ab&&" diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c index 2f5dfaa682..e366d7c929 100644 --- a/ext/standard/user_filters.c +++ b/ext/standard/user_filters.c @@ -260,6 +260,7 @@ static php_stream_filter *user_filter_factory_create(const char *filtername, zval *obj, *zfilter; zval func_name; zval *retval = NULL; + int len; /* some sanity checks */ if (persistent) { @@ -268,9 +269,10 @@ static php_stream_filter *user_filter_factory_create(const char *filtername, return NULL; } + len = strlen(filtername); + /* determine the classname/class entry */ - if (FAILURE == zend_hash_find(BG(user_filter_map), (char*)filtername, - strlen(filtername) + 1, (void**)&fdat)) { + if (FAILURE == zend_hash_find(BG(user_filter_map), (char*)filtername, len + 1, (void**)&fdat)) { char *period; /* Userspace Filters using ambiguous wildcards could cause problems. @@ -279,10 +281,10 @@ static php_stream_filter *user_filter_factory_create(const char *filtername, TODO: Allow failed userfilter creations to continue scanning through the list */ if ((period = strrchr(filtername, '.'))) { - char *wildcard; + char *wildcard = emalloc(len + 3); /* Search for wildcard matches instead */ - wildcard = estrdup(filtername); + memcpy(wildname, filtername, len + 1); /* copy \0 */ period = wildcard + (period - filtername); while (period) { *period = '\0'; diff --git a/ext/wddx/tests/bug41283.phpt b/ext/wddx/tests/bug41283.phpt new file mode 100644 index 0000000000..241101f2a4 --- /dev/null +++ b/ext/wddx/tests/bug41283.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #41283 (Bug with serializing array key that are doubles or floats) +--SKIPIF-- + +--FILE-- + array('1.1' => 'One 1','1.2' => 'One 2', '1.0' => 'Three') +); + +var_dump(wddx_deserialize(wddx_serialize_vars('data'))); +?> +--EXPECT-- +array(1) { + ["data"]=> + array(1) { + ["somearray"]=> + array(3) { + ["1.1"]=> + string(5) "One 1" + ["1.2"]=> + string(5) "One 2" + [1]=> + string(5) "Three" + } + } +} -- cgit v1.2.1