[php-pecl-jsonc] fix decode of string value with null-byte
Remi Collet
remi at fedoraproject.org
Thu Sep 26 06:44:50 UTC 2013
commit 59a648e56b2e83ef9eb9209832d4984d5573f24f
Author: Remi Collet <remi at fedoraproject.org>
Date: Thu Sep 26 08:44:36 2013 +0200
fix decode of string value with null-byte
.gitignore | 1 +
jsonc-nullbyte.patch | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++
php-pecl-jsonc.spec | 11 ++++++++-
3 files changed, 71 insertions(+), 1 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 52622ca..e454aeb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
+php-pecl-jsonc.spec~
/jsonc-1.3.1.tgz
/jsonc-1.3.2.tgz
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 at 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 at 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 0f41c43..3e7fcda 100644
--- a/php-pecl-jsonc.spec
+++ b/php-pecl-jsonc.spec
@@ -14,12 +14,16 @@
Summary: Support for JSON serialization
Name: php-pecl-%{proj_name}
Version: 1.3.2
-Release: 1%{?dist}
+Release: 2%{?dist}
License: PHP
Group: Development/Languages
URL: http://pecl.php.net/package/%{proj_name}
Source0: http://pecl.php.net/get/%{proj_name}-%{version}.tgz
+# partial fix to decode string with null-byte (only in value)
+# https://github.com/remicollet/pecl-json-c/issues/7
+Patch0: jsonc-nullbyte.patch
+
BuildRequires: php-devel >= 5.4
BuildRequires: php-pear
BuildRequires: pcre-devel
@@ -64,6 +68,8 @@ These are the files needed to compile programs using JSON serializer.
%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
@@ -155,6 +161,9 @@ fi
%changelog
+* Thu Sep 26 2013 Remi Collet <rcollet at redhat.com> - 1.3.2-2
+- fix decode of string value with null-byte
+
* Mon Sep 9 2013 Remi Collet <rcollet at redhat.com> - 1.3.2-1
- release 1.3.2 (stable)
More information about the scm-commits
mailing list