[compiler-rt] [win/asan] Ensure errno gets set correctly for strtol (PR #109258)

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 20 14:06:04 PDT 2024


================
@@ -650,9 +650,34 @@ static ALWAYS_INLINE auto StrtolImpl(void *ctx, Fn real, const char *nptr,
       return StrtolImpl(ctx, REAL(func), nptr, endptr, base);                \
     }
 
-INTERCEPTOR_STRTO_BASE(long, strtol)
 INTERCEPTOR_STRTO_BASE(long long, strtoll)
 
+#  if SANITIZER_WINDOWS
+INTERCEPTOR(long, strtol, const char *nptr, char **endptr, int base) {
+  // REAL(strtol) may be ntdll!strtol, which doesn't set errno. Instead,
----------------
rnk wrote:

Long term, we should stop patching ntdll for anything other than the purpose of intercepting heap allocation. For maintenance reasons, it's best not to touch the string routines in the minicrt inside of ntdll.

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


More information about the llvm-commits mailing list