commit: a80c36a0842224f29a28cb4c772da490996f5523
Author: Jakov Smolic sartura hr>
AuthorDate: Sun May 17 17:48:33 2020 +
Commit: Georgy Yakovlev gentoo org>
CommitDate: Mon May 18 21:41:34 2020 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a80c36a0
dev-libs/json-c: fix objects field limitation
Bug: https://bugs.gentoo.org/723480
Closes: https://github.com/gentoo/gentoo/pull/15852
Signed-off-by: Jakov Smolic sartura.hr>
Signed-off-by: Georgy Yakovlev gentoo.org>
.../files/json-c-0.14-object-limitation.patch | 93 ++
dev-libs/json-c/json-c-0.14-r3.ebuild | 54 +
2 files changed, 147 insertions(+)
diff --git a/dev-libs/json-c/files/json-c-0.14-object-limitation.patch
b/dev-libs/json-c/files/json-c-0.14-object-limitation.patch
new file mode 100644
index 000..ebd7ca80506
--- /dev/null
+++ b/dev-libs/json-c/files/json-c-0.14-object-limitation.patch
@@ -0,0 +1,93 @@
+From 519dfe1591d85432986f9762d41d1a883198c157 Mon Sep 17 00:00:00 2001
+From: Eric Haszlakiewicz
+Date: Sun, 10 May 2020 03:32:19 +
+Subject: [PATCH 01/13] Issue #599: Fix the backwards check in
+ lh_table_insert_w_hash() that was preventing adding more than 11 objects. Add
+ a test to check for this too.
+
+---
+ linkhash.c | 2 +-
+ tests/test4.c| 29 +
+ tests/test4.expected | 1 +
+ 3 files changed, 31 insertions(+), 1 deletion(-)
+
+diff --git a/linkhash.c b/linkhash.c
+index 51e90b1..f930efd 100644
+--- a/linkhash.c
b/linkhash.c
+@@ -582,7 +582,7 @@ int lh_table_insert_w_hash(struct lh_table *t, const void
*k, const void *v, con
+
+ if (t->count >= t->size * LH_LOAD_FACTOR) {
+ /* Avoid signed integer overflow with large tables. */
+- int new_size = INT_MAX / 2 < t->size ? t->size * 2 : INT_MAX;
++ int new_size = (t->size > INT_MAX / 2) ? INT_MAX : (t->size *
2);
+ if (t->size == INT_MAX || lh_table_resize(t, new_size) != 0)
+ return -1;
+ }
+diff --git a/tests/test4.c b/tests/test4.c
+index bd964ec..fd2f3be 100644
+--- a/tests/test4.c
b/tests/test4.c
+@@ -3,8 +3,10 @@
+ */
+
+ #include "config.h"
++#include
+ #include
+ #include
++#include
+
+ #include "json_inttypes.h"
+ #include "json_object.h"
+@@ -24,6 +26,30 @@ void print_hex(const char *s)
+ putchar('\n');
+ }
+
++static void test_lot_of_adds(void);
++static void test_lot_of_adds()
++{
++ int ii;
++ char key[50];
++ json_object *jobj = json_object_new_object();
++ assert(jobj != NULL);
++ for (ii = 0; ii < 500; ii++)
++ {
++ snprintf(key, sizeof(key), "k%d", ii);
++ json_object *iobj = json_object_new_int(ii);
++ assert(iobj != NULL);
++ if (json_object_object_add(jobj, key, iobj))
++ {
++ fprintf(stderr, "FAILED to add object #%d\n", ii);
++ abort();
++ }
++ }
++ printf("%s\n", json_object_to_json_string(jobj));
++ assert(json_object_object_length(jobj) == 500);
++ json_object_put(jobj);
++}
++
++
+ int main(void)
+ {
+ const char *input =
"\"\\ud840\\udd26,\\ud840\\udd27,\\ud800\\udd26,\\ud800\\udd27\"";
+@@ -52,5 +78,8 @@ int main(void)
+ retval = 1;
+ }
+ json_object_put(parse_result);
++
++ test_lot_of_adds();
++
+ return retval;
+ }
+diff --git a/tests/test4.expected b/tests/test4.expected
+index 68d4336..cb27440 100644
+--- a/tests/test4.expected
b/tests/test4.expected
+@@ -1,3 +1,4 @@
+ input: "\ud840\udd26,\ud840\udd27,\ud800\udd26,\ud800\udd27"
+ JSON parse result is correct: 𠄦,𠄧,𐄦,𐄧
+ PASS
++{ "k0": 0, "k1": 1, "k2": 2, "k3": 3, "k4": 4, "k5": 5, "k6": 6, "k7": 7,
"k8": 8, "k9": 9, "k10": 10, "k11": 11, "k12": 12, "k13": 13, "k14": 14, "k15":
15, "k16": 16, "k17": 17, "k18": 18, "k19": 19, "k20": 20, "k21": 21, "k22":
22, "k23": 23, "k24": 24, "k25": 25, "k26": 26, "k27": 27, "k28": 28, "k29":
29, "k30": 30, "k31": 31, "k32": 32, "k33": 33, "k34": 34, "k35": 35, "k36":
36, "k37": 37, "k38": 38, "k39": 39, "k40": 40, "k41": 41, "k42": 42, "k43":
43, "k44": 44, "k45": 45, "k46": 46, "k47": 47, "k48": 48, "k49": 49, "k50":
50, "k51": 51, "k52": 52, "k53": 53, "k54": 54, "k55": 55, "k56": 56, "k57":
57, "k58": 58, "k59": 59, "k60": 60, "k61": 61, "k62": 62, "k63": 63, "k64":
64, "k65": 65, "k66": 66, "k67": 67, "k68": 68, "k69": 69, "k70": 70, "k71":
71, "k72": 72, "k73": 73, "k74": 74, "k75": 75, "k76": 76, "k77": 77, "k78":
78, "k79": 79, "k80": 80, "k81": 81, "k82": 82, "k83": 83, "k84": 84, "k85":
85, "k86": 86, "k87": 87, "k88": 88, "k89": 89, "k90": 90, "k91": 91, "k
92": 92, "k93": 93, "k94": 94, "k95": 95, "k96": 96, "k97": 97, "k98": 98,
"k99": 99, "k100": 100, "k101": 101, "k102": 102, "k103": 103, "k104": 104,
"k105": 105, "k106": 106, "k107": 107, "k108": 108, "k109":