[libc-commits] [libc] [libc] fix oob and overflow bugs in wcslcat and wcsncat (PR #203697)

Jeff Bailey via libc-commits libc-commits at lists.llvm.org
Mon Jun 15 02:29:00 PDT 2026


https://github.com/kaladron requested changes to this pull request.

One minor change to the code, but also can you please revisit the commit message?  A commit message should be easy to read to see what's happened.  Something like this makes it more obvious what you intended and guides the reviewer to make sure that we see what you were aiming for.  Otherwise, the patch looks good!  Thank you!

[libc] Fix OOB read in wcsncat and overflow in wcslcat (#203697)

Prevented a potential buffer overflow in wcslcat and an out-of-bounds
read in wcsncat:

* wcslcat: Added an early exit when dstlen >= dstsize to avoid negative
limit calculations and integer wrap during static_cast.
* wcsncat: Reordered loop conditions to check bounds (i < n) before
dereferencing the source pointer (s2[i]).

Fixes #203649.

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


More information about the libc-commits mailing list