[PATCH] D55993: [Sanitizer] Enable fparseln/strtonum in FreeBSD

David CARLIER via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 21 03:39:13 PST 2018


devnexen created this revision.
devnexen added a reviewer: krytarowski.
devnexen created this object with visibility "All Users".
Herald added subscribers: Sanitizers, llvm-commits, fedor.sergeev, kubamracek, emaste.

- Exception for fparseln api in FreeBSD having its own version since it does not belong to the libc.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D55993

Files:
  lib/sanitizer_common/sanitizer_platform_interceptors.h
  test/sanitizer_common/TestCases/FreeBSD/fparseln.cc
  test/sanitizer_common/TestCases/NetBSD/strtonum.cc
  test/sanitizer_common/TestCases/Posix/strtonum.cc


Index: test/sanitizer_common/TestCases/Posix/strtonum.cc
===================================================================
--- test/sanitizer_common/TestCases/Posix/strtonum.cc
+++ test/sanitizer_common/TestCases/Posix/strtonum.cc
@@ -1,4 +1,6 @@
 // RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s
+//
+// UNSUPPORTED: linux, darwin, solaris
 
 #define _OPENBSD_SOURCE
 
Index: test/sanitizer_common/TestCases/FreeBSD/fparseln.cc
===================================================================
--- /dev/null
+++ test/sanitizer_common/TestCases/FreeBSD/fparseln.cc
@@ -0,0 +1,26 @@
+// RUN: %clangxx -O0 -g %s -lutil -o %t && %run %t 2>&1 | FileCheck %s
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <libutil.h>
+
+int main(void) {
+  printf("fparseln\n");
+
+  FILE *fp = fopen("/etc/fstab", "r");
+  assert(fp);
+
+  int flags = FPARSELN_UNESCALL;
+  const char *delim = "\\\\#";
+  size_t lineno = 0, len;
+  char *line;
+  while ((line = fparseln(fp, &len, &lineno, delim, flags))) {
+    printf("lineno: %zu, length: %zu, line: %s\n", lineno, len, line);
+    free(line);
+  }
+
+  // CHECK: fparseln
+
+  return 0;
+}
Index: lib/sanitizer_common/sanitizer_platform_interceptors.h
===================================================================
--- lib/sanitizer_common/sanitizer_platform_interceptors.h
+++ lib/sanitizer_common/sanitizer_platform_interceptors.h
@@ -530,11 +530,10 @@
 #define SANITIZER_INTERCEPT_NL_LANGINFO (SI_NETBSD || SI_FREEBSD || SI_MAC)
 #define SANITIZER_INTERCEPT_MODCTL SI_NETBSD
 #define SANITIZER_INTERCEPT_CAPSICUM SI_FREEBSD
-#define SANITIZER_INTERCEPT_STRTONUM SI_NETBSD
-#define SANITIZER_INTERCEPT_FPARSELN SI_NETBSD
+#define SANITIZER_INTERCEPT_STRTONUM (SI_NETBSD || SI_FREEBSD)
+#define SANITIZER_INTERCEPT_FPARSELN (SI_NETBSD || SI_FREEBSD)
 #define SANITIZER_INTERCEPT_STATVFS1 SI_NETBSD
 #define SANITIZER_INTERCEPT_STRTOI SI_NETBSD
-#define SANITIZER_INTERCEPT_CAPSICUM SI_FREEBSD
 #define SANITIZER_INTERCEPT_SHA1 SI_NETBSD
 #define SANITIZER_INTERCEPT_MD4 SI_NETBSD
 #define SANITIZER_INTERCEPT_RMD160 SI_NETBSD


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55993.179259.patch
Type: text/x-patch
Size: 2113 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181221/8278c1c8/attachment.bin>


More information about the llvm-commits mailing list