From: Darsh Kelaiya <[email protected]> This patch applies the upstream fix as referenced in [3], using the commit shown in [1]. It also applies the corrective follow-up [2], which fixes the snprintf() truncation boundary check. Both commits are included in gawk 5.4.1, identified as the fixed release in [4].
[1] https://cgit.git.savannah.gnu.org/cgit/gawk.git/commit/?id=cca0366144336b49aaa7d5d949966ce8e2c70843 [2] https://cgit.git.savannah.gnu.org/cgit/gawk.git/commit/?id=bfa2e4b890a44100a99d26b54af385479528b12e [3] https://nvd.nist.gov/vuln/detail/CVE-2026-40553 [4] https://cert.pl/en/posts/2026/07/CVE-2026-40467/ Signed-off-by: Darsh Kelaiya <[email protected]> --- .../gawk/gawk/CVE-2026-40553_p1.patch | 50 +++++++++++++++++++ .../gawk/gawk/CVE-2026-40553_p2.patch | 44 ++++++++++++++++ meta/recipes-extended/gawk/gawk_5.4.0.bb | 2 + 3 files changed, 96 insertions(+) create mode 100644 meta/recipes-extended/gawk/gawk/CVE-2026-40553_p1.patch create mode 100644 meta/recipes-extended/gawk/gawk/CVE-2026-40553_p2.patch diff --git a/meta/recipes-extended/gawk/gawk/CVE-2026-40553_p1.patch b/meta/recipes-extended/gawk/gawk/CVE-2026-40553_p1.patch new file mode 100644 index 0000000000..81e2efd6b9 --- /dev/null +++ b/meta/recipes-extended/gawk/gawk/CVE-2026-40553_p1.patch @@ -0,0 +1,50 @@ +From 6e7695c994aa45c0f7e9f8b80aa6f99717bbaf60 Mon Sep 17 00:00:00 2001 +From: "Arnold D. Robbins" <[email protected]> +Date: Wed, 15 Apr 2026 09:39:02 +0300 +Subject: [PATCH] Avoid buffer overflow in extension/readdir.c. + +CVE: CVE-2026-40553 +Upstream-Status: Backport [https://cgit.git.savannah.gnu.org/cgit/gawk.git/commit/?id=cca0366144336b49aaa7d5d949966ce8e2c70843] + +(cherry picked from commit cca0366144336b49aaa7d5d949966ce8e2c70843) +Signed-off-by: Darsh Kelaiya <[email protected]> +--- + extension/ChangeLog | 6 ++++++ + extension/readdir.c | 6 +++++- + 2 files changed, 11 insertions(+), 1 deletion(-) + +diff --git a/extension/ChangeLog b/extension/ChangeLog +index b11e83ac..6f88eb19 100644 +--- a/extension/ChangeLog ++++ b/extension/ChangeLog +@@ -1,3 +1,9 @@ ++2026-04-15 Arnold D. Robbins <[email protected]> ++ ++ * readdir.c (ftype): Use snprintf() to check for buffer ++ overflow in the file name before calling stat(). Thanks to ++ Marcin Wyczechowski <[email protected]> for the report. ++ + 2026-02-22 Arnold D. Robbins <[email protected]> + + * 5.4.0: Release tar ball made. +diff --git a/extension/readdir.c b/extension/readdir.c +index f876e168..5bbee261 100644 +--- a/extension/readdir.c ++++ b/extension/readdir.c +@@ -118,8 +118,12 @@ ftype(struct dirent *entry, const char *dirname) + #endif + char fname[PATH_MAX]; + struct stat sbuf; ++ int count; ++ ++ count = snprintf(fname, sizeof(fname), "%s/%s", dirname, entry->d_name); ++ if (count > sizeof(fname)) ++ return "u"; // buffer overflow. skip stat() call. + +- sprintf(fname, "%s/%s", dirname, entry->d_name); + if (stat(fname, &sbuf) == 0) { + if (S_ISBLK(sbuf.st_mode)) + return "b"; +-- +2.53.0 + diff --git a/meta/recipes-extended/gawk/gawk/CVE-2026-40553_p2.patch b/meta/recipes-extended/gawk/gawk/CVE-2026-40553_p2.patch new file mode 100644 index 0000000000..84bfdc5418 --- /dev/null +++ b/meta/recipes-extended/gawk/gawk/CVE-2026-40553_p2.patch @@ -0,0 +1,44 @@ +From a98440e83cb19b042958a179293bd637c400a35b Mon Sep 17 00:00:00 2001 +From: "Arnold D. Robbins" <[email protected]> +Date: Fri, 17 Apr 2026 11:48:19 +0300 +Subject: [PATCH] Small fix in extension/readdir.c. + +CVE: CVE-2026-40553 +Upstream-Status: Backport [https://cgit.git.savannah.gnu.org/cgit/gawk.git/commit/?id=bfa2e4b890a44100a99d26b54af385479528b12e] + +(cherry picked from commit bfa2e4b890a44100a99d26b54af385479528b12e) +Signed-off-by: Darsh Kelaiya <[email protected]> +--- + extension/ChangeLog | 5 +++++ + extension/readdir.c | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +diff --git a/extension/ChangeLog b/extension/ChangeLog +index 6f88eb19..9fe216e6 100644 +--- a/extension/ChangeLog ++++ b/extension/ChangeLog +@@ -1,3 +1,8 @@ ++2026-04-15 Arnold D. Robbins <[email protected]> ++ ++ * readdir.c (ftype): Use >= in check of snprintf() return ++ value. Thanks to Andrew Schorr <[email protected]>. ++ + 2026-04-15 Arnold D. Robbins <[email protected]> + + * readdir.c (ftype): Use snprintf() to check for buffer +diff --git a/extension/readdir.c b/extension/readdir.c +index 5bbee261..3cb31834 100644 +--- a/extension/readdir.c ++++ b/extension/readdir.c +@@ -121,7 +121,7 @@ ftype(struct dirent *entry, const char *dirname) + int count; + + count = snprintf(fname, sizeof(fname), "%s/%s", dirname, entry->d_name); +- if (count > sizeof(fname)) ++ if (count >= sizeof(fname)) + return "u"; // buffer overflow. skip stat() call. + + if (stat(fname, &sbuf) == 0) { +-- +2.53.0 + diff --git a/meta/recipes-extended/gawk/gawk_5.4.0.bb b/meta/recipes-extended/gawk/gawk_5.4.0.bb index a7c88224dd..f44d82b37c 100644 --- a/meta/recipes-extended/gawk/gawk_5.4.0.bb +++ b/meta/recipes-extended/gawk/gawk_5.4.0.bb @@ -31,6 +31,8 @@ SRC_URI = "${GNU_MIRROR}/gawk/gawk-${PV}.tar.xz \ file://CVE-2026-40467.patch \ file://CVE-2026-40468.patch \ file://CVE-2026-40469.patch \ + file://CVE-2026-40553_p1.patch \ + file://CVE-2026-40553_p2.patch \ " SRC_URI[sha256sum] = "3dd430f0cd3b4428c6c3f6afc021b9cd3c1f8c93f7a688dc268ca428a90b4ac1" -- 2.35.6
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#241638): https://lists.openembedded.org/g/openembedded-core/message/241638 Mute This Topic: https://lists.openembedded.org/mt/120391322/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
