[PATCH] D40052: [asan] Allow getpwnam(NULL) for binary compatibily
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 29 11:34:13 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rCRT319344: [asan] Allow getpwnam(NULL) for binary compatibility (authored by kuba.brecka).
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D40052
Files:
lib/sanitizer_common/sanitizer_common_interceptors.inc
test/asan/TestCases/Darwin/getpwnam.c
Index: lib/sanitizer_common/sanitizer_common_interceptors.inc
===================================================================
--- lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -1724,7 +1724,8 @@
INTERCEPTOR(__sanitizer_passwd *, getpwnam, const char *name) {
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, getpwnam, name);
- COMMON_INTERCEPTOR_READ_RANGE(ctx, name, REAL(strlen)(name) + 1);
+ if (name)
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, name, REAL(strlen)(name) + 1);
__sanitizer_passwd *res = REAL(getpwnam)(name);
if (res) unpoison_passwd(ctx, res);
return res;
Index: test/asan/TestCases/Darwin/getpwnam.c
===================================================================
--- test/asan/TestCases/Darwin/getpwnam.c
+++ test/asan/TestCases/Darwin/getpwnam.c
@@ -0,0 +1,15 @@
+// RUN: %clang_asan %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#include <pwd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
+int main(int argc, const char * argv[]) {
+ getpwnam(NULL);
+ fprintf(stderr, "Finished.\n");
+ return 0;
+}
+
+// CHECK: Finished.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40052.124792.patch
Type: text/x-patch
Size: 1161 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171129/4dbc809f/attachment.bin>
More information about the llvm-commits
mailing list