]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
cheri: Fix invalid pointer deref in wcpcpy_chk
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Tue, 21 Jun 2022 14:57:48 +0000 (15:57 +0100)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Fri, 5 Aug 2022 18:45:19 +0000 (19:45 +0100)
Accessing src via the dest pointer is invalid.

debug/wcpcpy_chk.c

index bc2be43c3e82a203cd8338bbb2094ec119153c95..d44fb479d02e646980b9e3199928efd847b4ae1a 100644 (file)
@@ -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');