Skip to contentSkip to conversation

yajl: fix CVE-2017-16516, CVE-2022-24795, CVE-2023-33460

PATCH New [email protected] 1 participant 1 message Nov 7, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 yajl: fix CVE-2017-16516, CVE-2022-24795, CVE-2023-33460

From: Ross Burton <[email protected]>

Take three CVE fixes from Fedora, as the upstream repository is now dead.

---
 .../yajl/yajl/CVE-2017-16516.patch            | 37 ++++++++++++
 .../yajl/yajl/CVE-2022-24795.patch            | 59 +++++++++++++++++++
 .../yajl/yajl/CVE-2023-33460.patch            | 35 +++++++++++
 meta-oe/recipes-devtools/yajl/yajl_2.1.0.bb   |  6 +-
 4 files changed, 136 insertions(+), 1 deletion(-)
 create mode 100644 meta-oe/recipes-devtools/yajl/yajl/CVE-2017-16516.patch
 create mode 100644 meta-oe/recipes-devtools/yajl/yajl/CVE-2022-24795.patch
 create mode 100644 meta-oe/recipes-devtools/yajl/yajl/CVE-2023-33460.patch
meta-oe/recipes-devtools/yajl/yajl/CVE-2017-16516.patch new file +37 -0
new file mode 100644
index 0000000000..1241ff9e31
@@ -0,0 +1,37 @@
+From 0b5e73c4321de0ba1d495fdc0967054b2a77931c Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <[email protected]>
+Date: Mon, 10 Jul 2023 13:36:10 +0100
+Subject: [PATCH] Fix for CVE-2017-16516
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Description: Fix for CVE-2017-16516
+ Potential buffer overread: A JSON file can cause denial of service.
+Origin: https://github.com/brianmario/yajl-ruby/commit/a8ca8f476655adaa187eedc60bdc770fff3c51ce
+
+CVE: CVE-2017-16516
+Upstream-Status: Submitted [https://github.com/lloyd/yajl/issues/248]
+Signed-off-by: Ross Burton <[email protected]>
+---
+ src/yajl_encode.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/yajl_encode.c b/src/yajl_encode.c
+index fd08258..0d97cc5 100644
+--- a/src/yajl_encode.c
++++ b/src/yajl_encode.c
+@@ -139,8 +139,8 @@ void yajl_string_decode(yajl_buf buf, const unsigned char * str,
+                     end+=3;
+                     /* check if this is a surrogate */
+                     if ((codepoint & 0xFC00) == 0xD800) {
+-                        end++;
+-                        if (str[end] == '\\' && str[end + 1] == 'u') {
++                        if (end + 2 < len && str[end + 1] == '\\' && str[end + 2] == 'u') {
++                            end++;
+                             unsigned int surrogate = 0;
+                             hexToDigit(&surrogate, str + end + 2);
+                             codepoint =
+-- 
+2.34.1
+
meta-oe/recipes-devtools/yajl/yajl/CVE-2022-24795.patch new file +59 -0

59 lines not on this page · raw message

meta-oe/recipes-devtools/yajl/yajl/CVE-2023-33460.patch new file +35 -0
new file mode 100644
index 0000000000..47454dc8af
@@ -0,0 +1,35 @@
+Fix memory leaks.  Taken from the Fedora packaging (https://src.fedoraproject.org/rpms/yajl)
+where it was backported from openEuler.
+
+CVE: CVE-2023-33460
+Upstream-Status: Submitted [https://github.com/lloyd/yajl/issues/250]
+Signed-off-by: Ross Burton <[email protected]>
+
+diff --git a/src/yajl_tree.c b/src/yajl_tree.c
+index 3d357a3..56c7012 100644
+--- a/src/yajl_tree.c
++++ b/src/yajl_tree.c
+@@ -143,7 +143,7 @@ static yajl_val context_pop(context_t *ctx)
+     ctx->stack = stack->next;
+ 
+     v = stack->value;
+-
++    free (stack->key);
+     free (stack);
+ 
+     return (v);
+@@ -444,7 +444,14 @@ yajl_val yajl_tree_parse (const char *input,
+              snprintf(error_buffer, error_buffer_size, "%s", internal_err_str);
+              YA_FREE(&(handle->alloc), internal_err_str);
+         }
++        while(ctx.stack != NULL) {
++             yajl_val v = context_pop(&ctx);
++             yajl_tree_free(v);
++        }
+         yajl_free (handle);
++	//If the requested memory is not released in time, it will cause memory leakage
++	if(ctx.root)
++	     yajl_tree_free(ctx.root);
+         return NULL;
+     }
+ 
meta-oe/recipes-devtools/yajl/yajl_2.1.0.bb +5 -1
index 33ffa41248..c5b5e60027 100644
@@ -8,7 +8,11 @@ HOMEPAGE = "https://lloyd.github.io/yajl/"
 LICENSE = "ISC"
 LIC_FILES_CHKSUM = "file://COPYING;md5=39af6eb42999852bdd3ea00ad120a36d"
 
-SRC_URI = "git://github.com/lloyd/yajl;branch=master;protocol=https"
+SRC_URI = "git://github.com/lloyd/yajl;branch=master;protocol=https \
+           file://CVE-2017-16516.patch \
+           file://CVE-2022-24795.patch \
+           file://CVE-2023-33460.patch \
+           "
 SRCREV = "a0ecdde0c042b9256170f2f8890dd9451a4240aa"
 
 S = "${WORKDIR}/git"
Signature · 1 line
2.34.1