From: Darsh Kelaiya <[email protected]>

This patch applies the upstream fix as referenced in [2], using the commit 
shown in [1].

[1] 
https://cgit.git.savannah.gnu.org/cgit/gawk.git/commit/?id=a2d18c74109e41bec29a23098eba2e00057286d8
[2] https://nvd.nist.gov/vuln/detail/CVE-2026-40467

Signed-off-by: Darsh Kelaiya <[email protected]>
---
 .../gawk/gawk/CVE-2026-40467.patch            | 63 +++++++++++++++++++
 meta/recipes-extended/gawk/gawk_5.3.0.bb      |  1 +
 2 files changed, 64 insertions(+)
 create mode 100644 meta/recipes-extended/gawk/gawk/CVE-2026-40467.patch

diff --git a/meta/recipes-extended/gawk/gawk/CVE-2026-40467.patch 
b/meta/recipes-extended/gawk/gawk/CVE-2026-40467.patch
new file mode 100644
index 0000000000..d813db5f8b
--- /dev/null
+++ b/meta/recipes-extended/gawk/gawk/CVE-2026-40467.patch
@@ -0,0 +1,63 @@
+From 22fd9e360251f70b34e9b46635b6d75bce49202f Mon Sep 17 00:00:00 2001
+From: "Arnold D. Robbins" <[email protected]>
+Date: Fri, 3 Apr 2026 12:02:11 +0300
+Subject: [PATCH] Small memory management fix in io.c.
+
+CVE: CVE-2026-40467
+Upstream-Status: Backport 
[https://cgit.git.savannah.gnu.org/cgit/gawk.git/commit/?id=a2d18c74109e41bec29a23098eba2e00057286d8]
+
+(cherry picked from commit a2d18c74109e41bec29a23098eba2e00057286d8)
+Signed-off-by: Darsh Kelaiya <[email protected]>
+---
+ ChangeLog | 6 ++++++
+ io.c      | 5 ++++-
+ 2 files changed, 10 insertions(+), 1 deletion(-)
+
+diff --git a/ChangeLog b/ChangeLog
+index 2fa8b2f0..6bc88ebb 100644
+--- a/ChangeLog
++++ b/ChangeLog
+@@ -1,3 +1,9 @@
++2026-04-03         Arnold D. Robbins     <[email protected]>
++
++      * io.c (do_getline_redir): Don't DEREF redir_exp too early.
++      Thanks to MichaƂ Majchrowicz <[email protected]>
++      for the report.
++
+ 2023-11-02         Arnold D. Robbins     <[email protected]>
+ 
+       * 5.3.0: Release tar ball made.
+diff --git a/io.c b/io.c
+index 44671ebd..4db4b21d 100644
+--- a/io.c
++++ b/io.c
+@@ -2836,22 +2836,25 @@ do_getline_redir(int into_variable, enum redirval 
redirtype)
+       assert(redirtype != redirect_none);
+       redir_exp = TOP();
+       rp = redirect(redir_exp, redirtype, & redir_error, false);
+-      DEREF(redir_exp);
+       decr_sp();
+       if (rp == NULL) {
+               if (redir_error) { /* failed redirect */
+                       if (! do_traditional)
+                               update_ERRNO_int(redir_error);
+               }
++              DEREF(redir_exp);
+               return make_number((AWKNUM) -1.0);
+       } else if ((rp->flag & RED_TWOWAY) != 0 && rp->iop == NULL) {
+               if (is_non_fatal_redirect(redir_exp->stptr, redir_exp->stlen)) {
+                       update_ERRNO_int(EBADF);
++                      DEREF(redir_exp);
+                       return make_number((AWKNUM) -1.0);
+               }
+               (void) close_rp(rp, CLOSE_ALL);
++              DEREF(redir_exp);       // we're about to die, but what the 
heck, release it anyway
+               fatal(_("getline: attempt to read from closed read end of 
two-way pipe"));
+       }
++      DEREF(redir_exp);
+       iop = rp->iop;
+       if (iop == NULL)                /* end of input */
+               return make_number((AWKNUM) 0.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 b1d1fe7ae4..56d7d7f76a 100644
--- a/meta/recipes-extended/gawk/gawk_5.3.0.bb
+++ b/meta/recipes-extended/gawk/gawk_5.3.0.bb
@@ -22,6 +22,7 @@ SRC_URI = "${GNU_MIRROR}/gawk/gawk-${PV}.tar.gz \
            file://0001-m4-readline-add-missing-includes.patch \
            file://run-ptest \
            file://0001-Fix-some-C23-compilatio-issues.patch \
+           file://CVE-2026-40467.patch \
            "
 
 SRC_URI[sha256sum] = 
"378f8864ec21cfceaa048f7e1869ac9b4597b449087caf1eb55e440d30273336"
-- 
2.35.6

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#241641): 
https://lists.openembedded.org/g/openembedded-core/message/241641
Mute This Topic: https://lists.openembedded.org/mt/120391334/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

  • ... Darsh Kelaiya -X (dkelaiya - E INFOCHIPS PRIVATE LIMITED at Cisco) via lists.openembedded.org
    • ... Darsh Kelaiya -X (dkelaiya - E INFOCHIPS PRIVATE LIMITED at Cisco) via lists.openembedded.org
      • ... Leonid Iziumtsev
    • ... Darsh Kelaiya -X (dkelaiya - E INFOCHIPS PRIVATE LIMITED at Cisco) via lists.openembedded.org
      • ... Leonid Iziumtsev
    • ... Darsh Kelaiya -X (dkelaiya - E INFOCHIPS PRIVATE LIMITED at Cisco) via lists.openembedded.org
      • ... Leonid Iziumtsev
    • ... Leonid Iziumtsev

Reply via email to