[compiler-rt] [compiler-rt][asan] Add wcscpy/wcsncpy; enable wcscat/wcsncat on Windows (PR #160493)

Yixuan Cao via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 25 02:39:00 PDT 2025


================
@@ -570,6 +579,20 @@ INTERCEPTOR(char *, strcpy, char *to, const char *from) {
   return REAL(strcpy)(to, from);
 }
 
+INTERCEPTOR(wchar_t *, wcscpy, wchar_t *to, const wchar_t *from) {
+  void *ctx;
+  ASAN_INTERCEPTOR_ENTER(ctx, wcscpy);
+  if (!TryAsanInitFromRtl())
+    return REAL(wcscpy)(to, from);
+  if (flags()->replace_str) {
+    uptr from_size = (internal_wcslen(from) + 1) * sizeof(wchar_t);
----------------
Cao-Wuhui wrote:

Rename `from_size` to `size` in wcscpy interceptor since it’s used for both source and destination checks. Submitted as a fixup; will autosquash before landing. Thanks @thurstond.

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


More information about the llvm-commits mailing list