From 00ea48ad43122c67c904965d4c315237740685ea Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Fri, 15 May 2015 02:42:11 +0200 Subject: [PATCH] Minor typo in warning message --- ext/zlib/tests/dictionary_usage.phpt | 2 +- ext/zlib/zlib.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ext/zlib/tests/dictionary_usage.phpt b/ext/zlib/tests/dictionary_usage.phpt index b73cd52d25..8ffa9e8bcd 100644 --- a/ext/zlib/tests/dictionary_usage.phpt +++ b/ext/zlib/tests/dictionary_usage.phpt @@ -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) diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index f09ba00cd5..31fe18db02 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -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; -- 2.40.0