]> granicus.if.org Git - php/commitdiff
Minor typo in warning message
authorBob Weinand <bobwei9@hotmail.com>
Fri, 15 May 2015 00:42:11 +0000 (02:42 +0200)
committerBob Weinand <bobwei9@hotmail.com>
Fri, 15 May 2015 00:42:11 +0000 (02:42 +0200)
ext/zlib/tests/dictionary_usage.phpt
ext/zlib/zlib.c

index b73cd52d251bd19fab8b323978db8fe6d4033963..8ffa9e8bcd9b496d12c1037b290c4a5ffb242ca1 100644 (file)
@@ -21,5 +21,5 @@ var_dump(inflate_add($r, $a, ZLIB_FINISH));
 string(%d) "%s"
 string(6) "abdcde"
 
-Warning: inflate_add(): dictionary does match expected dictionary (incorrect adler32 hash) in %s on line %d
+Warning: inflate_add(): dictionary does not match expected dictionary (incorrect adler32 hash) in %s on line %d
 bool(false)
index f09ba00cd5b532993b802ef5bb34e1ed7d1dfd0c..31fe18db021842e3d5b2ddfa6c0bf7db2da46489 100644 (file)
@@ -775,6 +775,8 @@ static zend_bool zlib_create_dictionary_string(HashTable *options, char **dict,
                        zend_string **end, **ptr = strings - 1;
 
                        ZEND_HASH_FOREACH_VAL(dictionary, cur) {
+                               int i;
+
                                *++ptr = zval_get_string(cur);
                                if (!*ptr || (*ptr)->len == 0) {
                                        if (*ptr) {
@@ -787,6 +789,16 @@ static zend_bool zlib_create_dictionary_string(HashTable *options, char **dict,
                                        php_error_docref(NULL, E_WARNING, "dictionary entries must be non-empty strings");
                                        return 0;
                                }
+                               for (i = 0; i < (*ptr)->len; i++) {
+                                       if ((*ptr)->val[i] == 0) {
+                                               do {
+                                                       efree(ptr);
+                                               } while (--ptr >= strings);
+                                               efree(strings);
+                                               php_error_docref(NULL, E_WARNING, "dictionary entries must not contain a NULL-byte");
+                                               return 0;
+                                       }
+                               }
 
                                *dictlen += (*ptr)->len + 1;
                        } ZEND_HASH_FOREACH_END();
@@ -950,7 +962,7 @@ PHP_FUNCTION(inflate_add)
                                                        php_ctx->inflateDict = NULL;
                                                        break;
                                                case Z_DATA_ERROR:
-                                                       php_error_docref(NULL, E_WARNING, "dictionary does match expected dictionary (incorrect adler32 hash)");
+                                                       php_error_docref(NULL, E_WARNING, "dictionary does not match expected dictionary (incorrect adler32 hash)");
                                                        efree(php_ctx->inflateDict);
                                                        zend_string_release(out);
                                                        php_ctx->inflateDict = NULL;