aboutsummaryrefslogtreecommitdiffstats
path: root/package/libs/libjson-c/patches/004-Issue-599-Fix-the-backwards-check-in-lh_table_insert.patch
diff options
context:
space:
mode:
authorRobert Marko <robert.marko@sartura.hr>2020-05-12 22:18:33 +0200
committerJo-Philipp Wich <jo@mein.io>2020-05-13 11:16:43 +0200
commitbc0288b76816578f5aeccb2abd679f82bfc5738e (patch)
tree288954142579aeac4854e5c0af1d273551e54486 /package/libs/libjson-c/patches/004-Issue-599-Fix-the-backwards-check-in-lh_table_insert.patch
parent2308644b0ce938bbdfe6155b12aae85dd02beea7 (diff)
downloadupstream-bc0288b76816578f5aeccb2abd679f82bfc5738e.tar.gz
upstream-bc0288b76816578f5aeccb2abd679f82bfc5738e.tar.bz2
upstream-bc0288b76816578f5aeccb2abd679f82bfc5738e.zip
libjson-c: backport security fixes
This backports upstream fixes for the out of bounds write vulnerability in json-c. It was reported and patches in this upstream PR: https://github.com/json-c/json-c/pull/592 Addresses CVE-2020-12762 Signed-off-by: Robert Marko <robert.marko@sartura.hr> Signed-off-by: Luka Perkov <luka.perkov@sartura.hr> [bump PKG_RELEASE] Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'package/libs/libjson-c/patches/004-Issue-599-Fix-the-backwards-check-in-lh_table_insert.patch')
-rw-r--r--package/libs/libjson-c/patches/004-Issue-599-Fix-the-backwards-check-in-lh_table_insert.patch29
1 files changed, 29 insertions, 0 deletions
diff --git a/package/libs/libjson-c/patches/004-Issue-599-Fix-the-backwards-check-in-lh_table_insert.patch b/package/libs/libjson-c/patches/004-Issue-599-Fix-the-backwards-check-in-lh_table_insert.patch
new file mode 100644
index 0000000000..aed6918e70
--- /dev/null
+++ b/package/libs/libjson-c/patches/004-Issue-599-Fix-the-backwards-check-in-lh_table_insert.patch
@@ -0,0 +1,29 @@
+From 519dfe1591d85432986f9762d41d1a883198c157 Mon Sep 17 00:00:00 2001
+From: Eric Haszlakiewicz <erh+git@nimenees.com>
+Date: Sun, 10 May 2020 03:32:19 +0000
+Subject: [PATCH] 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;
+ }
+--
+2.26.2
+