From: Szabolcs Nagy Date: Tue, 21 Jun 2022 14:57:48 +0000 (+0100) Subject: Fix invalid pointer dereference in wcpcpy_chk X-Git-Tag: glibc-2.37~211 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3fa20d59d9607e4494dfbc99bacee1935ec5ded9;p=thirdparty%2Fglibc.git 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 --- diff --git a/debug/wcpcpy_chk.c b/debug/wcpcpy_chk.c index bc2be43c3e8..d44fb479d02 100644 --- a/debug/wcpcpy_chk.c +++ b/debug/wcpcpy_chk.c @@ -28,13 +28,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');