diff --git a/backport-Fix-invalid-pointer-dereference-in-wcpcpy_chk.patch b/backport-Fix-invalid-pointer-dereference-in-wcpcpy_chk.patch new file mode 100644 index 0000000000000000000000000000000000000000..3594c5b219e6f203a4af8c4d3f0c63f4214d2791 --- /dev/null +++ b/backport-Fix-invalid-pointer-dereference-in-wcpcpy_chk.patch @@ -0,0 +1,35 @@ +From 4ee824be757337d8444fdc320aa1ca3e4397c906 Mon Sep 17 00:00:00 2001 +From: Szabolcs Nagy +Date: Tue, 21 Jun 2022 15:57:48 +0100 +Subject: [PATCH] Fix invalid pointer dereference in wcpcpy_chk + +The src pointer is const and points to a different object, so accessing +dest via src is invalid. + +Reviewed-by: Florian Weimer +--- + debug/wcpcpy_chk.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/debug/wcpcpy_chk.c b/debug/wcpcpy_chk.c +index 0e1d381a..16410e17 100644 +--- a/debug/wcpcpy_chk.c ++++ b/debug/wcpcpy_chk.c +@@ -29,13 +29,12 @@ __wcpcpy_chk (wchar_t *dest, const wchar_t *src, size_t destlen) + { + wchar_t *wcp = (wchar_t *) dest - 1; + wint_t c; +- const ptrdiff_t off = src - dest + 1; + + do + { + if (__glibc_unlikely (destlen-- == 0)) + __chk_fail (); +- c = wcp[off]; ++ c = *src++; + *++wcp = c; + } + while (c != L'\0'); +-- +2.27.0 + diff --git a/backport-Fix-invalid-pointer-dereference-in-wcscpy_chk.patch b/backport-Fix-invalid-pointer-dereference-in-wcscpy_chk.patch new file mode 100644 index 0000000000000000000000000000000000000000..1a3bec1a7ccd92da45074b4b247c6a97b7a60315 --- /dev/null +++ b/backport-Fix-invalid-pointer-dereference-in-wcscpy_chk.patch @@ -0,0 +1,64 @@ +From 1527ac4626b4bf1bcc46203481003a7f33e2aca5 Mon Sep 17 00:00:00 2001 +From: Szabolcs Nagy +Date: Tue, 21 Jun 2022 14:43:30 +0100 +Subject: [PATCH] Fix invalid pointer dereference in wcscpy_chk + +The src pointer is const and points to a different object, so accessing +dest via src is invalid. + +Reviewed-by: Florian Weimer +--- + debug/wcscpy_chk.c | 34 +++++++--------------------------- + 1 file changed, 7 insertions(+), 27 deletions(-) + +diff --git a/debug/wcscpy_chk.c b/debug/wcscpy_chk.c +index dfe475da..8115b00e 100644 +--- a/debug/wcscpy_chk.c ++++ b/debug/wcscpy_chk.c +@@ -25,36 +25,16 @@ wchar_t * + __wcscpy_chk (wchar_t *dest, const wchar_t *src, size_t n) + { + wint_t c; +- wchar_t *wcp; ++ wchar_t *wcp = dest; + +- if (__alignof__ (wchar_t) >= sizeof (wchar_t)) ++ do + { +- const ptrdiff_t off = dest - src - 1; +- +- wcp = (wchar_t *) src; +- +- do +- { +- if (__glibc_unlikely (n-- == 0)) +- __chk_fail (); +- c = *wcp++; +- wcp[off] = c; +- } +- while (c != L'\0'); +- } +- else +- { +- wcp = dest; +- +- do +- { +- if (__glibc_unlikely (n-- == 0)) +- __chk_fail (); +- c = *src++; +- *wcp++ = c; +- } +- while (c != L'\0'); ++ if (__glibc_unlikely (n-- == 0)) ++ __chk_fail (); ++ c = *src++; ++ *wcp++ = c; + } ++ while (c != L'\0'); + + return dest; + } +-- +2.27.0 + diff --git a/glibc.spec b/glibc.spec index c1d0a937cd5789e88d0a2023ba631c2b0572d257..f57076ac7a199837ec2df76f69b6786c6d5c67ab 100644 --- a/glibc.spec +++ b/glibc.spec @@ -66,7 +66,7 @@ ############################################################################## Name: glibc Version: 2.34 -Release: 143 +Release: 144 Summary: The GNU libc libraries License: %{all_license} URL: http://www.gnu.org/software/glibc/ @@ -280,6 +280,8 @@ Patch193: linux-use-statx-for-fstat-if-neither-newfstatat-nor-.patch Patch194: io-Do-not-implement-fstat-with-fstatat.patch Patch195: backport-posix-Fix-some-crashes-in-wordexp-BZ-18096.patch Patch196: backport-elf-Handle-non-directory-name-in-search-path-BZ-3103.patch +Patch197: backport-Fix-invalid-pointer-dereference-in-wcscpy_chk.patch +Patch198: backport-Fix-invalid-pointer-dereference-in-wcpcpy_chk.patch Patch9000: turn-default-value-of-x86_rep_stosb_threshold_form_2K_to_1M.patch Patch9001: delete-no-hard-link-to-avoid-all_language-package-to.patch @@ -1495,6 +1497,9 @@ fi %endif %changelog +* Fri Dec 29 2023 shixuantong - 2.34-144 +- Fix invalid pointer dereference in wcpcpy_chk and wcscpy_chk + * Thu Dec 14 2023 shixuantong - 2.34-143 - elf: Handle non-directory name in search path (BZ 31035)