diff options
author | Remi Collet <fedora@famillecollet.com> | 2013-09-26 08:34:23 +0200 |
---|---|---|
committer | Remi Collet <fedora@famillecollet.com> | 2013-09-26 08:34:23 +0200 |
commit | 23487e51faeb00ba2bcfb59c2d9a862f91efc60f (patch) | |
tree | a1fda611d346c6aaf78e4d9f5e753705c6704c7c | |
parent | 04959baf253e17f1d9d75cc64a740b5fa4cb22e0 (diff) |
php-pecl-jsonc: fix decode of string value with null-byte
-rw-r--r-- | jsonc-nullbyte.patch | 60 | ||||
-rw-r--r-- | php-pecl-jsonc.spec | 11 |
2 files changed, 70 insertions, 1 deletions
diff --git a/jsonc-nullbyte.patch b/jsonc-nullbyte.patch new file mode 100644 index 0000000..aa0b7f0 --- /dev/null +++ b/jsonc-nullbyte.patch @@ -0,0 +1,60 @@ +From c9200c8e207125ecec0fe377a5b06686a16d2c17 Mon Sep 17 00:00:00 2001 +From: Remi Collet <fedora@famillecollet.com> +Date: Thu, 26 Sep 2013 07:08:23 +0200 +Subject: [PATCH] properly decode string with null-byte, see #7 + +--- + json.c | 2 +- + package.xml | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/json.c b/json.c +index 0a98321..9568c2e 100644 +--- a/json.c ++++ b/json.c +@@ -801,7 +801,7 @@ static void json_object_to_zval(json_object *new_obj, zval *return_value, int o + break; + + case json_type_string: +- RETVAL_STRING(json_object_get_string(new_obj), 1); ++ RETVAL_STRINGL(json_object_get_string(new_obj), json_object_get_string_len(new_obj), 1); + break; + + case json_type_int: +-- +1.8.4 + +From d5a4d81f309d97aceb10d9ada0dff2bb72027c8d Mon Sep 17 00:00:00 2001 +From: Remi Collet <fedora@famillecollet.com> +Date: Thu, 26 Sep 2013 08:11:02 +0200 +Subject: [PATCH] add test for null-byte in value + +--- + tests/012-null-byte.phpt | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + create mode 100644 tests/012-null-byte.phpt + +diff --git a/tests/012-null-byte.phpt b/tests/012-null-byte.phpt +new file mode 100644 +index 0000000..c022710 +--- /dev/null ++++ b/tests/012-null-byte.phpt +@@ -0,0 +1,15 @@ ++--TEST-- ++Decode value with null-byte (key not yet properly decode) ++--SKIPIF-- ++<?php ++ if (!extension_loaded("json")) ++ die('skip: json extension not available'); ++?> ++--FILE-- ++<?php ++echo bin2hex(json_decode('"foo\u0000bar"')); ++echo "\nDone\n"; ++?> ++--EXPECT-- ++666f6f00626172 ++Done +-- +1.8.4 + diff --git a/php-pecl-jsonc.spec b/php-pecl-jsonc.spec index dea6b41..b318238 100644 --- a/php-pecl-jsonc.spec +++ b/php-pecl-jsonc.spec @@ -27,7 +27,7 @@ Summary: Support for JSON serialization Name: php-pecl-%{proj_name} Version: 1.3.2 -Release: 1%{?dist}.1 +Release: 2%{?dist}.1 License: PHP Group: Development/Languages URL: http://pecl.php.net/package/%{proj_name} @@ -41,6 +41,10 @@ BuildRequires: pcre-devel BuildRequires: json-c-devel >= 0.11 %endif +# partial fix to decode string with null-byte (only in value) +# https://github.com/remicollet/pecl-json-c/issues/7 +Patch0: jsonc-nullbyte.patch + Requires(post): %{__pecl} Requires(postun): %{__pecl} Requires: php(zend-abi) = %{php_zend_api} @@ -100,6 +104,8 @@ Only used to be the best provider for php-json. %setup -q -c cd %{proj_name}-%{version} +%patch0 -p1 + # Sanity check, really often broken extver=$(sed -n '/#define PHP_JSON_VERSION/{s/.* "//;s/".*$//;p}' php_json.h ) if test "x${extver}" != "x%{version}%{?prever:-%{prever}}"; then @@ -220,6 +226,9 @@ rm -rf %{buildroot} # Note to remi : remember to always build in remi-test first # %changelog +* Thu Sep 26 2013 Remi Collet <rcollet@redhat.com> - 1.3.2-2 +- fix decode of string value with null-byte + * Mon Sep 9 2013 Remi Collet <rcollet@redhat.com> - 1.3.2-1 - release 1.3.2 (stable) |