Fix invalid pointer dereference in wcpcpy_chk and wcscpy_chk
(cherry picked from commit eb2474daa03e009409d5070d7d822cab56da5169)
This commit is contained in:
parent
0425ae7d83
commit
1982405ab3
35
backport-Fix-invalid-pointer-dereference-in-wcpcpy_chk.patch
Normal file
35
backport-Fix-invalid-pointer-dereference-in-wcpcpy_chk.patch
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
From 4ee824be757337d8444fdc320aa1ca3e4397c906 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||||
|
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 <fweimer@redhat.com>
|
||||||
|
---
|
||||||
|
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
|
||||||
|
|
||||||
64
backport-Fix-invalid-pointer-dereference-in-wcscpy_chk.patch
Normal file
64
backport-Fix-invalid-pointer-dereference-in-wcscpy_chk.patch
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
From 1527ac4626b4bf1bcc46203481003a7f33e2aca5 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||||
|
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 <fweimer@redhat.com>
|
||||||
|
---
|
||||||
|
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
|
||||||
|
|
||||||
@ -66,7 +66,7 @@
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
Name: glibc
|
Name: glibc
|
||||||
Version: 2.34
|
Version: 2.34
|
||||||
Release: 143
|
Release: 144
|
||||||
Summary: The GNU libc libraries
|
Summary: The GNU libc libraries
|
||||||
License: %{all_license}
|
License: %{all_license}
|
||||||
URL: http://www.gnu.org/software/glibc/
|
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
|
Patch194: io-Do-not-implement-fstat-with-fstatat.patch
|
||||||
Patch195: backport-posix-Fix-some-crashes-in-wordexp-BZ-18096.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
|
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
|
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
|
Patch9001: delete-no-hard-link-to-avoid-all_language-package-to.patch
|
||||||
@ -1495,6 +1497,9 @@ fi
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Dec 29 2023 shixuantong <shixuantong1@huawei.com> - 2.34-144
|
||||||
|
- Fix invalid pointer dereference in wcpcpy_chk and wcscpy_chk
|
||||||
|
|
||||||
* Thu Dec 14 2023 shixuantong <shixuantong1@huawei.com> - 2.34-143
|
* Thu Dec 14 2023 shixuantong <shixuantong1@huawei.com> - 2.34-143
|
||||||
- elf: Handle non-directory name in search path (BZ 31035)
|
- elf: Handle non-directory name in search path (BZ 31035)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user