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.3.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..07b7df488a --- /dev/null +++ b/meta/recipes-extended/gawk/gawk/CVE-2026-40553_p1.patch @@ -0,0 +1,50 @@ +From aa39cac4bda6333be0f6253ecb7dfade26cb9641 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 40ed6dd0..52a4c6ab 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. ++ + 2023-11-02 Arnold D. Robbins <[email protected]> + + * 5.3.0: Release tar ball made. +diff --git a/extension/readdir.c b/extension/readdir.c +index 788e1d1e..b525fe21 100644 +--- a/extension/readdir.c ++++ b/extension/readdir.c +@@ -117,8 +117,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.44.4 + 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..2f63572af0 --- /dev/null +++ b/meta/recipes-extended/gawk/gawk/CVE-2026-40553_p2.patch @@ -0,0 +1,44 @@ +From 8b08dcf6c784e7a98d08e9e63a8fda15040eee30 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 52a4c6ab..c8839357 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 b525fe21..6f9b6811 100644 +--- a/extension/readdir.c ++++ b/extension/readdir.c +@@ -120,7 +120,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.44.4 + diff --git a/meta/recipes-extended/gawk/gawk_5.3.0.bb b/meta/recipes-extended/gawk/gawk_5.3.0.bb index 7bd34a3ff8..d71f655ba6 100644 --- a/meta/recipes-extended/gawk/gawk_5.3.0.bb +++ b/meta/recipes-extended/gawk/gawk_5.3.0.bb @@ -25,6 +25,8 @@ SRC_URI = "${GNU_MIRROR}/gawk/gawk-${PV}.tar.gz \ 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] = "378f8864ec21cfceaa048f7e1869ac9b4597b449087caf1eb55e440d30273336" -- 2.35.6
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#241643): https://lists.openembedded.org/g/openembedded-core/message/241643 Mute This Topic: https://lists.openembedded.org/mt/120391336/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
