[PATCH] D31457: [asan] Add strndup/__strndup interceptors if targeting linux.

Filipe Cabecinhas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 11 10:40:23 PDT 2017


filcab added inline comments.


================
Comment at: lib/sanitizer_common/sanitizer_common_interceptors.inc:330
+  void *ctx;
+  COMMON_INTERCEPTOR_ENTER(ctx, strndup, s, size);
+  uptr from_length = REAL(strlen)(s);
----------------
Should the context be `__strndup`?
It's probably ok as it is if the `__strndup` function is not supposed to be user-visible.


================
Comment at: lib/sanitizer_common/tests/sanitizer_test_utils.h:127
 
+#if defined(__linux__) && !defined(__ANDROID__)
+# define SANITIZER_TEST_HAS_STRNDUP 1
----------------
We should also enter here if `defined(__APPLE__)` and if `defined(__FreeBSD__)`, I think.
Can't think of more OS we support that should be here.

I'm not sure we should be taking Android out of the picture, as it seems `strndup` is available, AFAICT. @kcc/@vitalybuka (or others who might be working on Android) can you confirm if we should expect `strndup` to be available?


================
Comment at: test/asan/TestCases/strndup_oob_test.cc:9
+
+// REQUIRES: linux
+// XFAIL: android
----------------
I don't think this should require Linux. It should have Windows as unsupported, but should work on all (?) POSIX.
Maybe just put it in TestCases/Posix?


https://reviews.llvm.org/D31457





More information about the llvm-commits mailing list