glibc: Fix CVE-2026-5450
PATCH v3 1/2 glibc: Fix CVE-2026-5450
From: Sourav Kumar Pramanik <[email protected]>
NVD describes CVE-2026-5450 as a one-byte heap buffer overflow in the scanf family when using %mc with an explicit field width greater than 1024. The affected versions are glibc 2.7 through 2.43, including the 2.39 version used by this recipe.
Backport upstream commit 839898 fixes the buffer-growth calculation in vfscanf-internal.c, which can allocate one element too few, and adds a regression test using %1040mc with malloc checking enabled.
Reference: https://nvd.nist.gov/vuln/detail/CVE-2026-5450
Comment: Refreshed for glibc 2.39[adjusted source hunk locations and Makefile contexts]
--- .../glibc/glibc/CVE-2026-5450.patch | 132 ++++++++++++++++++ meta/recipes-core/glibc/glibc_2.39.bb | 1 + 2 files changed, 133 insertions(+) create mode 100644 meta/recipes-core/glibc/glibc/CVE-2026-5450.patch
meta/recipes-core/glibc/glibc/CVE-2026-5450.patch new file +132 -0
@@ -0,0 +1,132 @@ +From 839898777226a3ed88c0859f25ffe712519b4ead Mon Sep 17 00:00:00 2001 +From: Rocket Ma <[email protected]> +Date: Fri, 17 Apr 2026 23:48:41 -0700 +Subject: [PATCH] stdio-common: Fix buffer overflow in scanf %mc [BZ #34008] + +* stdio-common/vfscanf-internal.c: When enlarging allocated buffer with +format %mc or %mC, glibc allocates one byte less, leading to +user-controlled one byte overflow. This commit fixes BZ #34008, or +CVE-2026-5450. + +CVE: CVE-2026-5450 +Upstream-Status: Backport [https://sourceware.org/cgit/glibc/commit/?id=839898777226a3ed88c0859f25ffe712519b4ead] +Comment: Refreshed for glibc 2.39[adjusted source hunk locations and +Makefile contexts] + +Reviewed-by: Carlos O'Donell <[email protected]> +Signed-off-by: Rocket Ma <[email protected]> +Reviewed-by: H.J. Lu <[email protected]> +Signed-off-by: Sourav Kumar Pramanik <[email protected]> +--- + stdio-common/Makefile | 4 ++++ + stdio-common/tst-vfscanf-bz34008.c | 48 ++++++++++++++++++++++++++++++++++++++++ + stdio-common/vfscanf-internal.c | 6 ++--- + 3 files changed, 55 insertions(+), 3 deletions(-) + create mode 100644 stdio-common/tst-vfscanf-bz34008.c + +diff --git a/stdio-common/Makefile b/stdio-common/Makefile +--- a/stdio-common/Makefile ++++ b/stdio-common/Makefile +@@ -266,6 +266,7 @@ tests := \ + tst-vfprintf-width-i18n \ + tst-vfprintf-width-prec \ + tst-vfprintf-width-prec-alloc \ ++ tst-vfscanf-bz34008 \ + tst-wc-printf \ + tstdiomisc \ + tstgetln \ +@@ -401,6 +402,9 @@ tst-printf-bz18872-ENV = MALLOC_TRACE=$(objpfx)tst-printf-bz18872.mtrace \ + tst-vfprintf-width-prec-ENV = \ + MALLOC_TRACE=$(objpfx)tst-vfprintf-width-prec.mtrace \ + LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so ++tst-vfscanf-bz34008-ENV = \ ++ MALLOC_CHECK_=3 \ ++ LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so + tst-printf-bz25691-ENV = \ + MALLOC_TRACE=$(objpfx)tst-printf-bz25691.mtrace \ + LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so +diff --git a/stdio-common/tst-vfscanf-bz34008.c b/stdio-common/tst-vfscanf-bz34008.c +new file mode 100644 +--- /dev/null ++++ b/stdio-common/tst-vfscanf-bz34008.c +@@ -0,0 +1,48 @@ ++/* Regression test for vfscanf %Nmc out-of-bound write (BZ #34008) ++ Copyright (C) 2026 The GNU Toolchain Authors. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, see ++ <https://www.gnu.org/licenses/>. */ ++ ++#include "malloc/mcheck.h" ++#include <stddef.h> ++#include <stdio.h> ++#include <string.h> ++#include <wchar.h> ++#include <stdlib.h> ++#include <malloc.h> ++#include <support/check.h> ++ ++#define WIDTH 0x410 ++#define SCANFSTR "%1040mc" ++static int ++do_test (void) ++{ ++ mcheck_pedantic (NULL); ++ char *input = malloc (WIDTH + 1); ++ TEST_VERIFY (input != NULL); ++ memset (input, 'A', WIDTH); ++ input[WIDTH] = '\0'; ++ ++ char *buf = NULL; ++ TEST_VERIFY (sscanf (input, SCANFSTR, &buf) != -1); ++ TEST_VERIFY (buf != NULL); ++ ++ free (buf); ++ free (input); ++ return 0; ++} ++ ++#include <support/test-driver.c> +diff --git a/stdio-common/vfscanf-internal.c b/stdio-common/vfscanf-internal.c +--- a/stdio-common/vfscanf-internal.c ++++ b/stdio-common/vfscanf-internal.c +@@ -854,7 +854,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, + /* Enlarge the buffer. */ + size_t newsize + = strsize +- + (strsize >= width ? width - 1 : strsize); ++ + (strsize >= width ? width : strsize); + + str = (char *) realloc (*strptr, newsize); + if (str == NULL) +@@ -925,7 +925,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, + && wstr == (wchar_t *) *strptr + strsize) + { + size_t newsize +- = strsize + (strsize > width ? width - 1 : strsize); ++ = strsize + (strsize >= width ? width : strsize); + /* Enlarge the buffer. */ + wstr = (wchar_t *) realloc (*strptr, + newsize * sizeof (wchar_t)); +@@ -980,7 +980,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, + && wstr == (wchar_t *) *strptr + strsize) + { + size_t newsize +- = strsize + (strsize > width ? width - 1 : strsize); ++ = strsize + (strsize >= width ? width : strsize); + /* Enlarge the buffer. */ + wstr = (wchar_t *) realloc (*strptr, + newsize * sizeof (wchar_t)); +-- +2.43.0
meta/recipes-core/glibc/glibc_2.39.bb +1 -0
@@ -63,6 +63,7 @@ SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \ file://0028-CVE-2026-6238-0004.patch \ file://0029-CVE-2026-6238-0005.patch \ file://0030-CVE-2026-6238-0006.patch \ + file://CVE-2026-5450.patch \ " S = "${WORKDIR}/git" B = "${WORKDIR}/build-${TARGET_SYS}"
Signature · 1 line
2.43.0
PATCH v3 2/2 glibc: Fix CVE-2026-5928
From: Sourav Kumar Pramanik <[email protected]>
NVD describes CVE-2026-5928 as a buffer under-read in ungetwc in glibc 2.43 and earlier, including the 2.39 version used here. With certain character encodings, this can disclose neighboring heap data. An uninitialized byte-stream read pointer can also cause a program crash.
Backport upstream commit ef3bfb5f910011f3780cb06aa47e730035f53285. It fixes _IO_wdefault_pbackfail to compare and decrement the wide stream read pointer instead of the byte stream read pointer. The regression test checks that ungetwc leaves the byte stream read pointer unchanged.
Reference: https://nvd.nist.gov/vuln/detail/CVE-2026-5928
Comment: Refreshed for glibc 2.39[adjusted source hunk locations and Makefile contexts]
--- .../glibc/glibc/CVE-2026-5928.patch | 112 ++++++++++++++++++ meta/recipes-core/glibc/glibc_2.39.bb | 1 + 2 files changed, 113 insertions(+) create mode 100644 meta/recipes-core/glibc/glibc/CVE-2026-5928.patch
meta/recipes-core/glibc/glibc/CVE-2026-5928.patch new file +112 -0
@@ -0,0 +1,112 @@ +From ef3bfb5f910011f3780cb06aa47e730035f53285 Mon Sep 17 00:00:00 2001 +From: Rocket Ma <[email protected]> +Date: Fri, 1 May 2026 20:39:07 -0700 +Subject: [PATCH] libio: Fix ungetwc operating on byte stream [BZ #33998] + +* libio/wgenops.c: When _IO_wdefault_pbackfail attempts to push back one +character, it accidently compare the wchar to push back with the last +char from byte stream, instead of wide stream. Under specific coding, +attacker may exploit this to leak information. This commit fix bug +33998, or CVE-2026-5928. + +CVE: CVE-2026-5928 +Upstream-Status: Backport [https://sourceware.org/git/?p=glibc.git;a=commit;h=ef3bfb5f910011f3780cb06aa47e730035f53285] +Comment: Refreshed for glibc 2.39[adjusted source hunk locations and +Makefile contexts] + +Signed-off-by: Rocket Ma <[email protected]> +Reviewed-by: Carlos O'Donell <[email protected]> +Signed-off-by: Sourav Kumar Pramanik <[email protected]> +--- + libio/Makefile | 1 + + libio/bug-wgenops-bz33998.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++ + libio/wgenops.c | 4 ++-- + 3 files changed, 57 insertions(+), 2 deletions(-) + create mode 100644 libio/bug-wgenops-bz33998.c + +diff --git a/libio/Makefile b/libio/Makefile +--- a/libio/Makefile ++++ b/libio/Makefile +@@ -83,6 +83,7 @@ tests = \ + bug-ungetwc1 \ + bug-ungetwc2 \ + bug-wfflush \ ++ bug-wgenops-bz33998 \ + bug-wmemstream1 \ + bug-wsetpos \ + test-fmemopen \ +diff --git a/libio/bug-wgenops-bz33998.c b/libio/bug-wgenops-bz33998.c +new file mode 100644 +--- /dev/null ++++ b/libio/bug-wgenops-bz33998.c +@@ -0,0 +1,54 @@ ++/* Regression test for ungetwc operating on byte stream (BZ #33998) ++ Copyright (C) 2026 The GNU Toolchain Authors. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, see ++ <https://www.gnu.org/licenses/>. */ ++ ++#include "support/temp_file.h" ++#include "support/xstdio.h" ++#include "support/xunistd.h" ++#include <stdlib.h> ++#include <unistd.h> ++#include <sys/mman.h> ++#include <stdio.h> ++#include <wchar.h> ++#include <support/check.h> ++ ++static int ++do_test (void) ++{ ++ char *filename; ++ int fd = create_temp_file ("tst-bz33998-", &filename); ++ TEST_VERIFY (fd != -1); ++ xwrite (fd, "A", sizeof ("A")); // write "A\0" by design ++ xclose (fd); ++ ++ FILE *fp = xfopen (filename, "r+"); ++ TEST_COMPARE (getwc (fp), L'A'); ++ /* If the bug is fixed, then ungetwc should not touch byte stream. ++ If the bug is not fixed, ungetwc firstly match last read char, L'A', ++ failed, then the pbackfail branch, matching last read char in byte ++ stream, that is, '\0' (initialized when setup wide stream). */ ++ char *old_read_ptr = fp->_IO_read_ptr; ++ TEST_COMPARE (ungetwc (L'\0', fp), L'\0'); ++ TEST_VERIFY (fp->_IO_read_ptr == old_read_ptr); ++ ++ xfclose (fp); ++ free (filename); ++ ++ return 0; ++} ++ ++#include <support/test-driver.c> +diff --git a/libio/wgenops.c b/libio/wgenops.c +--- a/libio/wgenops.c ++++ b/libio/wgenops.c +@@ -108,8 +108,8 @@ _IO_wdefault_pbackfail (FILE *fp, wint_t c) + { + if (fp->_wide_data->_IO_read_ptr > fp->_wide_data->_IO_read_base + && !_IO_in_backup (fp) +- && (wint_t) fp->_IO_read_ptr[-1] == c) +- --fp->_IO_read_ptr; ++ && (wint_t) fp->_wide_data->_IO_read_ptr[-1] == c) ++ --fp->_wide_data->_IO_read_ptr; + else + { + /* Need to handle a filebuf in write mode (switch to read mode). FIXME!*/ +-- +2.43.0
meta/recipes-core/glibc/glibc_2.39.bb +1 -0
@@ -64,6 +64,7 @@ SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \ file://0029-CVE-2026-6238-0005.patch \ file://0030-CVE-2026-6238-0006.patch \ file://CVE-2026-5450.patch \ + file://CVE-2026-5928.patch \ " S = "${WORKDIR}/git" B = "${WORKDIR}/build-${TARGET_SYS}"
Signature · 1 line
2.43.0
RE: [OE-core] [scarthgap][PATCH v3 2/2] glibc: Fix CVE-2026-5928
This is already patched, see https://git.openembedded.org/openembedded-core/commit/?h=scarthgap&id=3459c342137aea6a59c43b80289d30a84d0a3148
Peter
Quoted 174 lines
-----Original Message-----
From: Sourav Kumar Pramanik via openembedded-core <UpStream_IP- [email protected]>
Sent: Thursday, November 12, 2026 12:58 PM
To: [email protected]
Cc: Sourav Kumar Pramanik <[email protected]>
Subject: [OE-core] [scarthgap][PATCH v3 2/2] glibc: Fix CVE-2026-5928From: Sourav Kumar Pramanik <[email protected]>
NVD describes CVE-2026-5928 as a buffer under-read in ungetwc in glibc 2.43 and earlier, including the 2.39 version used here. With certain character encodings, this can disclose neighboring heap data. An uninitialized byte-stream read pointer can also cause a program crash.
Backport upstream commit
ef3bfb5f910011f3780cb06aa47e730035f53285. It fixes_IO_wdefault_pbackfailto compare and decrement the wide stream read pointer instead of the byte stream read pointer. The regression test checks that ungetwc leaves the byte stream read pointer unchanged.Reference: https://nvd.nist.gov/vuln/detail/CVE-2026-5928
Comment: Refreshed for glibc 2.39[adjusted source hunk locations and
Makefilecontexts]Signed-off-by: Sourav Kumar Pramanik
<[email protected]>--- .../glibc/glibc/CVE-2026-5928.patch | 112 ++++++++++++++++++ meta/recipes-core/glibc/glibc_2.39.bb | 1 + 2 files changed, 113 insertions(+) create mode 100644 meta/recipes-core/glibc/glibc/CVE-2026-5928.patchmeta/recipes- renamed from meta/recipes-core/glibc/glibc/CVE-2026-5928.patch +0
-0
core/glibc/glibc/CVE-2026-5928.patch
new file mode 100644meta/recipes-core/glibc/glibc/CVE-2026-5928.patch new file +1
-0@@ -0,0 +1,112 @@ +From ef3bfb5f910011f3780cb06aa47e730035f53285 Mon Sep 17 00:00:002001
meta/recipes-core/glibc/glibc/CVE-2026-5928.patch new file +12
-0+From: Rocket Ma <[email protected]> +Date: Fri, 1 May 2026 20:39:07 -0700 +Subject: [PATCH] libio: Fix ungetwc operating on byte stream [BZ #33998] + +* libio/wgenops.c: When _IO_wdefault_pbackfail attempts to push back one +character, it accidently compare the wchar to push back with the last +char from byte stream, instead of wide stream. Under specific coding, +attacker may exploit this to leak information. This commit fix bug +33998, or CVE-2026-5928. + +CVE: CVE-2026-5928 +Upstream-Status: Backport[https://sourceware.org/git/?p=glibc.git;a=commit;h=ef3bfb5f910011f3780cb06aa4
7e730035f53285]meta/recipes-core/glibc/glibc/CVE-2026-5928.patch new file +6
-0+Comment: Refreshed for glibc 2.39[adjusted source hunk locations and +Makefile contexts] + +Signed-off-by: Rocket Ma <[email protected]> +Reviewed-by: Carlos O'Donell <[email protected]> +Signed-off-by: Sourav Kumar Pramanik+--- + libio/Makefile | 1 + + libio/bug-wgenops-bz33998.c | 54++++++++++++++++++++++++++++++++++++++++++++++
+libio/wgenops.c| 4 ++--
+ 3 files changed, 57 insertions(+), 2 deletions(-)
+ create mode 100644libio/bug-wgenops-bz33998.cmeta/recipes-core/glibc/glibc/CVE-2026-5928.patch new file +29
-0+ +diff --git a/libio/Makefile b/libio/Makefile +--- a/libio/Makefile ++++ b/libio/Makefile +@@ -83,6 +83,7 @@ tests = \ + bug-ungetwc1 \ + bug-ungetwc2 \ + bug-wfflush \ ++ bug-wgenops-bz33998 \ + bug-wmemstream1 \ + bug-wsetpos \ + test-fmemopen \ +diff --git a/libio/bug-wgenops-bz33998.c b/libio/bug-wgenops-bz33998.c +new file mode 100644 +--- /dev/null ++++ b/libio/bug-wgenops-bz33998.c +@@ -0,0 +1,54 @@ ++/* Regression test for ungetwc operating on byte stream (BZ #33998) ++ Copyright (C) 2026 The GNU Toolchain Authors. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU
++ Lesser General Public License for more details.
++++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, see ++ <https://www.gnu.org/licenses/>. */++
++#include "support/temp_file.h"
++#include "support/xstdio.h"
++#include "support/xunistd.h"
++#include <stdlib.h>
++#include <unistd.h>
++#include <sys/mman.h>
++#include <stdio.h>
++#include <wchar.h>
++#include <support/check.h>
++
++static int
++do_test (void)
++{++ char *filename; ++ int fd = create_temp_file ("tst-bz33998-", &filename); ++ TEST_VERIFY (fd != -1); ++ xwrite (fd, "A", sizeof ("A")); // write "A\0" by design ++ xclose (fd); ++ ++ FILE *fp = xfopen (filename, "r+"); ++ TEST_COMPARE (getwc (fp), L'A'); ++ /* If the bug is fixed, then ungetwc should not touch byte stream. ++ If the bug is not fixed, ungetwc firstly match last read char, L'A', ++ failed, then the pbackfail branch, matching last read char in byte ++ stream, that is, '\0' (initialized when setup wide stream). */ ++ char *old_read_ptr = fp->_IO_read_ptr; ++ TEST_COMPARE (ungetwc (L'\0', fp), L'\0'); ++ TEST_VERIFY (fp->_IO_read_ptr == old_read_ptr);++
++ xfclose (fp);
++ free (filename);
++
++ return 0;
++}
++
++#include <support/test-driver.c>meta/recipes-core/glibc/glibc/CVE-2026-5928.patch new file +16
-0+diff --git a/libio/wgenops.c b/libio/wgenops.c +--- a/libio/wgenops.c ++++ b/libio/wgenops.c +@@ -108,8 +108,8 @@ _IO_wdefault_pbackfail (FILE *fp, wint_t c) + { + if (fp->_wide_data->_IO_read_ptr > fp->_wide_data->_IO_read_base + && !_IO_in_backup (fp) +- && (wint_t) fp->_IO_read_ptr[-1] == c) +- --fp->_IO_read_ptr; ++ && (wint_t) fp->_wide_data->_IO_read_ptr[-1] == c) ++ --fp->_wide_data->_IO_read_ptr; + else + { + /* Need to handle a filebuf in write mode (switch to read mode). FIXME!*/ +-- +2.43.0meta/recipes- renamed from meta/recipes-core/glibc/glibc_2.39.bb +0
-0core/glibc/glibc_2.39.bb
meta/recipes-core/glibc/glibc_2.39.bb +1
-0@@ -64,6 +64,7 @@ SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \ file://0029-CVE-2026-6238-0005.patch \ file://0030-CVE-2026-6238-0006.patch \ file://CVE-2026-5450.patch \ + file://CVE-2026-5928.patch \ " S = "${WORKDIR}/git"B = "${WORKDIR}/build-${TARGET_SYS}"
--
2.43.0
This is already patched, see https://git.openembedded.org/openembedded-core/commit/?h=scarthgap&id=3eb9b43fb0bcfc2c49aa884f1e7cde8a1f032dd8
Peter
Quoted 197 lines
-----Original Message-----
From: Sourav Kumar Pramanik via openembedded-core <UpStream_IP- [email protected]>
Sent: Thursday, November 12, 2026 12:58 PM
To: [email protected]
Cc: Sourav Kumar Pramanik <[email protected]>
Subject: [OE-core] [scarthgap][PATCH v3 1/2] glibc: Fix CVE-2026-5450From: Sourav Kumar Pramanik <[email protected]>
NVD describes CVE-2026-5450 as a one-byte heap buffer overflow in the scanf family when using %mc with an explicit field width greater than 1024. The affected versions are glibc 2.7 through 2.43, including the 2.39 version used by this recipe.
Backport upstream commit 839898 fixes the buffer-growth calculation in
vfscanf-internal.c, which can allocate one element too few, and adds a regression test using %1040mc with malloc checking enabled.Reference: https://nvd.nist.gov/vuln/detail/CVE-2026-5450
Comment: Refreshed for glibc 2.39[adjusted source hunk locations and
Makefilecontexts]Signed-off-by: Sourav Kumar Pramanik
<[email protected]>--- .../glibc/glibc/CVE-2026-5450.patch | 132 ++++++++++++++++++ meta/recipes-core/glibc/glibc_2.39.bb | 1 + 2 files changed, 133 insertions(+) create mode 100644 meta/recipes-core/glibc/glibc/CVE-2026-5450.patchmeta/recipes- renamed from meta/recipes-core/glibc/glibc/CVE-2026-5450.patch +0
-0
core/glibc/glibc/CVE-2026-5450.patch
new file mode 100644meta/recipes-core/glibc/glibc/CVE-2026-5450.patch new file +1
-0@@ -0,0 +1,132 @@ +From 839898777226a3ed88c0859f25ffe712519b4ead Mon Sep 17 00:00:002001
meta/recipes-core/glibc/glibc/CVE-2026-5450.patch new file +11
-0+From: Rocket Ma <[email protected]> +Date: Fri, 17 Apr 2026 23:48:41 -0700 +Subject: [PATCH] stdio-common: Fix buffer overflow in scanf %mc [BZ #34008] + +* stdio-common/vfscanf-internal.c: When enlarging allocated buffer with +format %mc or %mC, glibc allocates one byte less, leading to +user-controlled one byte overflow. This commit fixes BZ #34008, or +CVE-2026-5450. + +CVE: CVE-2026-5450 +Upstream-Status: Backport[https://sourceware.org/cgit/glibc/commit/?id=839898777226a3ed88c0859f25ffe7
12519b4ead]meta/recipes-core/glibc/glibc/CVE-2026-5450.patch new file +7
-0+Comment: Refreshed for glibc 2.39[adjusted source hunk locations and +Makefile contexts] + +Reviewed-by: Carlos O'Donell <[email protected]> +Signed-off-by: Rocket Ma <[email protected]> +Reviewed-by: H.J. Lu <[email protected]> +Signed-off-by: Sourav Kumar Pramanik+--- + stdio-common/Makefile | 4 ++++ + stdio-common/tst-vfscanf-bz34008.c | 48++++++++++++++++++++++++++++++++++++++++
+stdio-common/vfscanf-internal.c| 6 ++---
+ 3 files changed, 55 insertions(+), 3 deletions(-)
+ create mode 100644stdio-common/tst-vfscanf-bz34008.cmeta/recipes-core/glibc/glibc/CVE-2026-5450.patch new file +13
-0+ +diff --git a/stdio-common/Makefile b/stdio-common/Makefile +--- a/stdio-common/Makefile ++++ b/stdio-common/Makefile +@@ -266,6 +266,7 @@ tests := \ + tst-vfprintf-width-i18n \ + tst-vfprintf-width-prec \ + tst-vfprintf-width-prec-alloc \ ++ tst-vfscanf-bz34008 \ + tst-wc-printf \ + tstdiomisc \ + tstgetln \ +@@ -401,6 +402,9 @@ tst-printf-bz18872-ENV =MALLOC_TRACE=$(objpfx)tst-printf-bz18872.mtrace \
+ tst-vfprintf-width-prec-ENV = \meta/recipes-core/glibc/glibc/CVE-2026-5450.patch new file +9
-0+ MALLOC_TRACE=$(objpfx)tst-vfprintf-width-prec.mtrace \ + LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so ++tst-vfscanf-bz34008-ENV = \ ++ MALLOC_CHECK_=3 \ ++ LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so + tst-printf-bz25691-ENV = \ + MALLOC_TRACE=$(objpfx)tst-printf-bz25691.mtrace \ + LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so +diff --git a/stdio-common/tst-vfscanf-bz34008.c b/stdio-common/tst-vfscanf-
bz34008.c
+new file mode 100644
+---/dev/null
++++b/stdio-common/tst-vfscanf-bz34008.c
+@@ -0,0 +1,48 @@
++/* Regression test for vfscanf %Nmc out-of-bound write (BZ #34008)
++ Copyright (C) 2026 The GNU Toolchain Authors.
++ This file is part of the GNU C Library.
++++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, see ++ <https://www.gnu.org/licenses/>. */++
++#include "malloc/mcheck.h"
++#include <stddef.h>
++#include <stdio.h>
++#include <string.h>
++#include <wchar.h>
++#include <stdlib.h>
++#include <malloc.h>
++#include <support/check.h>
++
++#define WIDTH0x410
++#define SCANFSTR "%1040mc"
++static int
++do_test (void)
++{++ mcheck_pedantic (NULL); ++ char *input = malloc (WIDTH + 1); ++ TEST_VERIFY (input != NULL); ++ memset (input, 'A', WIDTH); ++ input[WIDTH] = '\0'; ++ ++ char *buf = NULL; ++ TEST_VERIFY (sscanf (input, SCANFSTR, &buf) != -1); ++ TEST_VERIFY (buf != NULL); ++ ++ free (buf); ++ free (input); ++ return 0;++}
++
++#include <support/test-driver.c>
+diff --gita/stdio-common/vfscanf-internal.cb/stdio-common/vfscanf-internal.c+---a/stdio-common/vfscanf-internal.c
++++b/stdio-common/vfscanf-internal.c
+@@ -854,7 +854,7 @@__vfscanf_internal(FILE *s, const char *format,va_listargptr,meta/recipes-core/glibc/glibc/CVE-2026-5450.patch new file +9
-0+ /* Enlarge the buffer. */ + size_t newsize + = strsize +- + (strsize >= width ? width - 1 : strsize); ++ + (strsize >= width ? width : strsize); + + str = (char *) realloc (*strptr, newsize); + if (str == NULL) +@@ -925,7 +925,7 @@ __vfscanf_internal (FILE *s, const char *format, va_listargptr,
meta/recipes-core/glibc/glibc/CVE-2026-5450.patch new file +9
-0+ && wstr == (wchar_t *) *strptr + strsize) + { + size_t newsize +- = strsize + (strsize > width ? width - 1 : strsize); ++ = strsize + (strsize >= width ? width : strsize); + /* Enlarge the buffer. */ + wstr = (wchar_t *) realloc (*strptr, + newsize * sizeof (wchar_t)); +@@ -980,7 +980,7 @@ __vfscanf_internal (FILE *s, const char *format, va_listargptr,
meta/recipes-core/glibc/glibc/CVE-2026-5450.patch new file +10
-0+ && wstr == (wchar_t *) *strptr + strsize) + { + size_t newsize +- = strsize + (strsize > width ? width - 1 : strsize); ++ = strsize + (strsize >= width ? width : strsize); + /* Enlarge the buffer. */ + wstr = (wchar_t *) realloc (*strptr, + newsize * sizeof (wchar_t)); +-- +2.43.0meta/recipes- renamed from meta/recipes-core/glibc/glibc_2.39.bb +0
-0core/glibc/glibc_2.39.bb
meta/recipes-core/glibc/glibc_2.39.bb +1
-0@@ -63,6 +63,7 @@ SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \ file://0028-CVE-2026-6238-0004.patch \ file://0029-CVE-2026-6238-0005.patch \ file://0030-CVE-2026-6238-0006.patch \ + file://CVE-2026-5450.patch \ " S = "${WORKDIR}/git"B = "${WORKDIR}/build-${TARGET_SYS}"
--
2.43.0