[packages/jansson] 0017-Fix-error-handling-in-json_pack.patch added

jajcus jajcus at pld-linux.org
Thu Sep 6 09:36:21 CEST 2018


commit 9e72a0ef56241c73b26421dde0e56f5bf65b745a
Author: Jacek Konieczny <j.konieczny at eggsoft.pl>
Date:   Thu Sep 6 09:35:51 2018 +0200

    0017-Fix-error-handling-in-json_pack.patch added
    
    from Asterisk
    
    Release: 2

 0017-Fix-error-handling-in-json_pack.patch | 103 +++++++++++++++++++++++++++++
 jansson.spec                               |   4 +-
 2 files changed, 106 insertions(+), 1 deletion(-)
---
diff --git a/jansson.spec b/jansson.spec
index 9e45528..27979d9 100644
--- a/jansson.spec
+++ b/jansson.spec
@@ -7,11 +7,12 @@ Summary:	C library for encoding, decoding and manipulating JSON data
 Summary(pl.UTF-8):	Biblioteka C do kodowania, dekodowania i obróbki danych JSON
 Name:		jansson
 Version:	2.11
-Release:	1
+Release:	2
 License:	MIT
 Group:		Libraries
 Source0:	http://www.digip.org/jansson/releases/%{name}-%{version}.tar.bz2
 # Source0-md5:	289ca8cbd2df31de9bda7e5220754d25
+Patch0:		0017-Fix-error-handling-in-json_pack.patch
 URL:		http://www.digip.org/jansson/
 BuildRequires:	autoconf >= 2.60
 BuildRequires:	automake >= 1:1.10
@@ -77,6 +78,7 @@ Dokumentacja API biblioteki %{name}.
 
 %prep
 %setup -q
+%patch0 -p1
 
 %build
 %{__libtoolize}
diff --git a/0017-Fix-error-handling-in-json_pack.patch b/0017-Fix-error-handling-in-json_pack.patch
new file mode 100644
index 0000000..affa6c9
--- /dev/null
+++ b/0017-Fix-error-handling-in-json_pack.patch
@@ -0,0 +1,103 @@
+From 15105b66b4df387037b670ac713584194ea10c2f Mon Sep 17 00:00:00 2001
+From: Maxim Zhukov <mussitantesmortem at gmail.com>
+Date: Mon, 12 Mar 2018 17:39:04 +0300
+Subject: [PATCH 17/22] Fix error handling in json_pack
+
+Changes to test/ removed.
+
+Fixed a bug where the error message was not filled if an empty object
+was passed to the json_pack.
+
+Fixes #271
+---
+ src/pack_unpack.c           | 64 ++++++++++++++++++-------------------
+ test/suites/api/test_pack.c |  8 +++++
+ 2 files changed, 40 insertions(+), 32 deletions(-)
+
+diff --git a/src/pack_unpack.c b/src/pack_unpack.c
+index 4026fd9..6461c06 100644
+--- a/src/pack_unpack.c
++++ b/src/pack_unpack.c
+@@ -348,6 +348,36 @@ static json_t *pack_string(scanner_t *s, va_list *ap)
+     }
+ }
+ 
++static json_t *pack_object_inter(scanner_t *s, va_list *ap, int need_incref)
++{
++    json_t *json;
++    char ntoken;
++
++    next_token(s);
++    ntoken = token(s);
++
++    if (ntoken != '?')
++        prev_token(s);
++
++    json = va_arg(*ap, json_t *);
++
++    if (json)
++        return need_incref ? json_incref(json) : json;
++
++    switch (ntoken) {
++        case '?':
++            return json_null();
++        case '*':
++            return NULL;
++        default:
++            break;
++    }
++
++    set_error(s, "<args>", json_error_null_value, "NULL object key");
++    s->has_error = 1;
++    return NULL;
++}
++
+ static json_t *pack(scanner_t *s, va_list *ap)
+ {
+     switch(token(s)) {
+@@ -376,40 +406,10 @@ static json_t *pack(scanner_t *s, va_list *ap)
+             return json_real(va_arg(*ap, double));
+ 
+         case 'O': /* a json_t object; increments refcount */
+-        {
+-            int nullable;
+-            json_t *json;
+-
+-            next_token(s);
+-            nullable = token(s) == '?';
+-            if (!nullable)
+-                prev_token(s);
+-
+-            json = va_arg(*ap, json_t *);
+-            if (!json && nullable) {
+-                return json_null();
+-            } else {
+-                return json_incref(json);
+-            }
+-        }
++            return pack_object_inter(s, ap, 1);
+ 
+         case 'o': /* a json_t object; doesn't increment refcount */
+-        {
+-            int nullable;
+-            json_t *json;
+-
+-            next_token(s);
+-            nullable = token(s) == '?';
+-            if (!nullable)
+-                prev_token(s);
+-
+-            json = va_arg(*ap, json_t *);
+-            if (!json && nullable) {
+-                return json_null();
+-            } else {
+-                return json;
+-            }
+-        }
++            return pack_object_inter(s, ap, 0);
+ 
+         default:
+             set_error(s, "<format>", json_error_invalid_format, "Unexpected format character '%c'",
+-- 
+2.17.1
+
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/jansson.git/commitdiff/9e72a0ef56241c73b26421dde0e56f5bf65b745a



More information about the pld-cvs-commit mailing list