diff options
| -rw-r--r-- | meta-oe/recipes-devtools/jq/jq/CVE-2026-32316.patch | 55 | ||||
| -rw-r--r-- | meta-oe/recipes-devtools/jq/jq_1.7.1.bb | 1 |
2 files changed, 56 insertions, 0 deletions
diff --git a/meta-oe/recipes-devtools/jq/jq/CVE-2026-32316.patch b/meta-oe/recipes-devtools/jq/jq/CVE-2026-32316.patch new file mode 100644 index 0000000000..2f2ff2145f --- /dev/null +++ b/meta-oe/recipes-devtools/jq/jq/CVE-2026-32316.patch | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | From 0814c321b08415c18165deac419f0d60a4a7664f Mon Sep 17 00:00:00 2001 | ||
| 2 | From: itchyny <itchyny@cybozu.co.jp> | ||
| 3 | Date: Thu, 12 Mar 2026 20:28:43 +0900 | ||
| 4 | Subject: [PATCH] Fix heap buffer overflow in `jvp_string_append` and | ||
| 5 | `jvp_string_copy_replace_bad` | ||
| 6 | |||
| 7 | In `jvp_string_append`, the allocation size `(currlen + len) * 2` could | ||
| 8 | overflow `uint32_t` when `currlen + len` exceeds `INT_MAX`, causing a small | ||
| 9 | allocation followed by a large `memcpy`. | ||
| 10 | |||
| 11 | In `jvp_string_copy_replace_bad`, the output buffer size calculation | ||
| 12 | `length * 3 + 1` could overflow `uint32_t`, again resulting in a small | ||
| 13 | allocation followed by a large write. | ||
| 14 | |||
| 15 | Add overflow checks to both functions to return an error for strings | ||
| 16 | that would exceed `INT_MAX` in length. Fixes CVE-2026-32316. | ||
| 17 | |||
| 18 | (cherry picked from commit e47e56d226519635768e6aab2f38f0ab037c09e5) | ||
| 19 | |||
| 20 | CVE: CVE-2026-32316 | ||
| 21 | Upstream-Status: Backport [https://github.com/jqlang/jq/commit/e47e56d226519635768e6aab2f38f0ab037c09e5] | ||
| 22 | Signed-off-by: Ankur Tyagi <ankur.tyagi85@gmail.com> | ||
| 23 | --- | ||
| 24 | src/jv.c | 11 ++++++++++- | ||
| 25 | 1 file changed, 10 insertions(+), 1 deletion(-) | ||
| 26 | |||
| 27 | diff --git a/src/jv.c b/src/jv.c | ||
| 28 | index 18dbb54..73387d8 100644 | ||
| 29 | --- a/src/jv.c | ||
| 30 | +++ b/src/jv.c | ||
| 31 | @@ -1091,7 +1091,12 @@ static jv jvp_string_copy_replace_bad(const char* data, uint32_t length) { | ||
| 32 | const char* end = data + length; | ||
| 33 | const char* i = data; | ||
| 34 | |||
| 35 | - uint32_t maxlength = length * 3 + 1; // worst case: all bad bytes, each becomes a 3-byte U+FFFD | ||
| 36 | + // worst case: all bad bytes, each becomes a 3-byte U+FFFD | ||
| 37 | + uint64_t maxlength = (uint64_t)length * 3 + 1; | ||
| 38 | + if (maxlength >= INT_MAX) { | ||
| 39 | + return jv_invalid_with_msg(jv_string("String too long")); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | jvp_string* s = jvp_string_alloc(maxlength); | ||
| 43 | char* out = s->data; | ||
| 44 | int c = 0; | ||
| 45 | @@ -1151,6 +1156,10 @@ static uint32_t jvp_string_remaining_space(jvp_string* s) { | ||
| 46 | static jv jvp_string_append(jv string, const char* data, uint32_t len) { | ||
| 47 | jvp_string* s = jvp_string_ptr(string); | ||
| 48 | uint32_t currlen = jvp_string_length(s); | ||
| 49 | + if ((uint64_t)currlen + len >= INT_MAX) { | ||
| 50 | + jv_free(string); | ||
| 51 | + return jv_invalid_with_msg(jv_string("String too long")); | ||
| 52 | + } | ||
| 53 | |||
| 54 | if (jvp_refcnt_unshared(string.u.ptr) && | ||
| 55 | jvp_string_remaining_space(s) >= len) { | ||
diff --git a/meta-oe/recipes-devtools/jq/jq_1.7.1.bb b/meta-oe/recipes-devtools/jq/jq_1.7.1.bb index 566e8017dc..c0211ca8bd 100644 --- a/meta-oe/recipes-devtools/jq/jq_1.7.1.bb +++ b/meta-oe/recipes-devtools/jq/jq_1.7.1.bb | |||
| @@ -16,6 +16,7 @@ SRC_URI = "${GITHUB_BASE_URI}/download/${BPN}-${PV}/${BPN}-${PV}.tar.gz \ | |||
| 16 | file://CVE-2025-48060.patch \ | 16 | file://CVE-2025-48060.patch \ |
| 17 | file://CVE-2025-9403.patch \ | 17 | file://CVE-2025-9403.patch \ |
| 18 | file://CVE-2026-40164.patch \ | 18 | file://CVE-2026-40164.patch \ |
| 19 | file://CVE-2026-32316.patch \ | ||
| 19 | " | 20 | " |
| 20 | SRC_URI[sha256sum] = "478c9ca129fd2e3443fe27314b455e211e0d8c60bc8ff7df703873deeee580c2" | 21 | SRC_URI[sha256sum] = "478c9ca129fd2e3443fe27314b455e211e0d8c60bc8ff7df703873deeee580c2" |
| 21 | 22 | ||
