[libc-commits] [libc] [libc][wchar] Fix OOB read and integer underflow in wcslcat and wcsncat (PR #203704)

Schrodinger ZHU Yifan via libc-commits libc-commits at lists.llvm.org
Mon Jun 15 08:01:26 PDT 2026


================
@@ -19,21 +19,23 @@ namespace LIBC_NAMESPACE_DECL {
 LLVM_LIBC_FUNCTION(size_t, wcslcat,
                    (wchar_t *__restrict dst, const wchar_t *__restrict src,
                     size_t dstsize)) {
-  const size_t dstlen = internal::string_length(dst);
+  size_t dstlen = 0;
+  while (dstlen < dstsize && dst[dstlen] != L'\0') {
+    dstlen++;
+  }
----------------
SchrodingerZhu wrote:

Please elide ambiguous single-level braces based on LLVM style guide.

https://github.com/llvm/llvm-project/pull/203704


More information about the libc-commits mailing list