[PATCH] D112998: [sanitizer_common] Fix readlink error handling in sanitizer_procmaps_solaris.cpp
Rainer Orth via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 2 14:06:47 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGde6f7252daf5: [sanitizer_common] Fix readlink error handling in sanitizer_procmaps_solaris.cpp (authored by Rich Lowe <richlowe at richlowe.net>, committed by ro).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112998/new/
https://reviews.llvm.org/D112998
Files:
compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp
Index: compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp
+++ compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp
@@ -55,7 +55,15 @@
internal_snprintf(proc_path, sizeof(proc_path), "/proc/self/path/%s",
xmapentry->pr_mapname);
- internal_readlink(proc_path, segment->filename, segment->filename_size);
+ ssize_t sz = internal_readlink(proc_path, segment->filename,
+ segment->filename_size - 1);
+
+ // If readlink failed, the map is anonymous.
+ if (sz == -1) {
+ segment->filename[0] = '\0';
+ } else if ((size_t)sz < segment->filename_size)
+ // readlink doesn't NUL-terminate.
+ segment->filename[sz] = '\0';
}
data_.current += sizeof(prxmap_t);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112998.384225.patch
Type: text/x-patch
Size: 913 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211102/e5a7ba88/attachment.bin>
More information about the llvm-commits
mailing list