[PATCH] [compiler-rt] Allow suppression file paths be relative to the location of the executable.

Alexey Samsonov vonosmas at gmail.com
Tue Feb 17 17:03:14 PST 2015


================
Comment at: lib/sanitizer_common/sanitizer_mac.cc:217
@@ +216,3 @@
+  uint32_t size = exe_path.size();
+  if (_NSGetExecutablePath(exe_path.data(), &size) == 0)
+    if (realpath(exe_path.data(), buf) != 0)
----------------
You can merge these conditions with &&

================
Comment at: lib/sanitizer_common/sanitizer_suppressions.cc:83
@@ -82,1 +82,3 @@
 
+static bool GetPathRelativeToExec(const char *file_path,
+                                  /*out*/char *rel_file_path) {
----------------
Function name looks confusing: it return an absolute path, not path relative to executable.

================
Comment at: lib/sanitizer_common/sanitizer_suppressions.cc:86
@@ +85,3 @@
+  InternalScopedString exec(kMaxPathLength);
+  if (ReadBinaryName(exec.data(), exec.size())) {
+    const char *file_name_pos = StripModuleName(exec.data());
----------------
  if (!ReadBinaryName(exec.data(), exec.size()))
    return false;
  ...
  return true;

================
Comment at: lib/sanitizer_common/sanitizer_suppressions.cc:89
@@ +88,3 @@
+    uptr path_to_exec_len = file_name_pos - exec.data();
+    internal_memcpy(rel_file_path, exec.data(), path_to_exec_len);
+    internal_memcpy(rel_file_path + path_to_exec_len,
----------------
You can have a buffer overflow on rel_file_path here. Consider taking a length of rel_file_path buffer as an input argument and/or using internal_strncat.

================
Comment at: lib/sanitizer_common/sanitizer_suppressions.cc:108
@@ -90,1 +107,3 @@
   uptr buffer_size;
+  uptr max_len = 1 << 26;
+
----------------
const

================
Comment at: lib/sanitizer_common/sanitizer_win.cc:320
@@ +319,3 @@
+bool IsPathSeparator(const char c) {
+  UNIMPLEMENTED();
+}
----------------
return c == '\\';

http://reviews.llvm.org/D7309

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list