summaryrefslogtreecommitdiff
path: root/alloc-stress
diff options
context:
space:
mode:
authorRajeev Kumar <rajekumar@google.com>2018-05-08 14:14:30 -0700
committerRajeev Kumar <rajekumar@google.com>2018-05-08 15:16:09 -0700
commit34b5ed247cf41ff9889a9e9c3a413e017e690f58 (patch)
treec853ccc0e8e1ee6ff2c8a4f969fe6ccdfb888da1 /alloc-stress
parent6f14272775fdf15ea8d7d616bc75ce6103a2226b (diff)
downloadextras-34b5ed247cf41ff9889a9e9c3a413e017e690f58.tar.gz
Append null byte to exPath.
Note: Without this fix on Android Go device exPath gets some junk chars at the end of exPath because readlink() does not append a null byte to buf. Bug: 79430762 Test: Tested manually by running alloc-stress on Android Go device. Change-Id: I8e09d8c6d670b7d29e7f98c00dd8e9e9c5492169
Diffstat (limited to 'alloc-stress')
-rw-r--r--alloc-stress/alloc-stress.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/alloc-stress/alloc-stress.cpp b/alloc-stress/alloc-stress.cpp
index fcb074b6..1cd8fddf 100644
--- a/alloc-stress/alloc-stress.cpp
+++ b/alloc-stress/alloc-stress.cpp
@@ -124,6 +124,9 @@ pid_t createProcess(Pipe pipe, const char *exName,
ssize_t exPathLen = readlink("/proc/self/exe", exPath, sizeof(exPath));
bool isExPathAvailable =
exPathLen != -1 && exPathLen < static_cast<ssize_t>(sizeof(exPath));
+ if (isExPathAvailable) {
+ exPath[exPathLen] = '\0';
+ }
execl(isExPathAvailable ? exPath : exName, exName, "--worker", arg, readFdStr, writeFdStr,
use_memcg ? "1" : "0", nullptr);
ASSERT_TRUE(0);