The ASanified executable could be launched from different locations. When we cannot find the suppression file relative to the current directory, try to see if the specified path is relative to the location of the executable.
Thanks for working on this!
kcc@: We don't have file with default suppressions, do we?
This can cause memory corruption if the length of the result is larger than buf_len. If you intend to call realpath(), you should probably store the result in the pre-allocated buffer of size at least kMaxPathLength, and then internal_strncpy it into buf.
Please make the output parameter last.
+1. Looks like we need a named constant for path separator that would be different on POSIX/Windows. It can also be used in functions like StripPathPrefix or StripModuleName.
You might add a VPrintf() that would tell the actual path of the file with suppressions used by the runtime.
I assume that the default suppressions are the bugs in libraries we already know about, correct?
My understanding is that those are currently baked into the ASan library.
This workflow is needed for cases where a user runs into an issue in a third party library, which they want to suppress. Allowing them to add the suppressions file can unblock them immediately.
- Made this friendly to Windows. (Introduced "IsPathSeparator()" instead of a constant since multiple characters can serve as separators on Windows.)
- Addressed all other comments.
- Included a testcase, which I forgot to add the first time around.
You can merge these conditions with &&
Function name looks confusing: it return an absolute path, not path relative to executable.
if (!ReadBinaryName(exec.data(), exec.size())) return false; ... return true;
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.
return c == '\\';
LGTM after addressing a few comments below. Thanks!
return path != nullptr && IsPathSeparator(path)
Max(path_to_exec_len, new_file_path_size - 1);
Move these declarations closer to the place where they are actually used.
should this be file_path?