[PATCH] egltrace/android: Fix tracing Zygote processes (v2)
Alexander Monakov
amonakov at ispras.ru
Mon Jun 17 10:05:33 PDT 2013
Oops, that patch would break more than it fixed :)
v2: manually zero-terminate the path returned from readlink
diff --git a/common/os_posix.cpp b/common/os_posix.cpp
index 7ddd895..bffa359 100644
--- a/common/os_posix.cpp
+++ b/common/os_posix.cpp
@@ -74,11 +74,12 @@ getProcessName(void)
*buf = 0;
return path;
}
- len = strlen(buf);
#else
ssize_t len;
len = readlink("/proc/self/exe", buf, size - 1);
- if (len == -1) {
+ if (len != -1) {
+ buf[len] = 0;
+ } else {
// /proc/self/exe is not available on setuid processes, so fallback to
// /proc/self/cmdline.
int fd = open("/proc/self/cmdline", O_RDONLY);
@@ -92,7 +93,7 @@ getProcessName(void)
return path;
}
#endif
- path.truncate(len);
+ path.truncate();
return path;
}
diff --git a/wrappers/trace.cpp b/wrappers/trace.cpp
index d79b11b..33b5cf1 100644
--- a/wrappers/trace.cpp
+++ b/wrappers/trace.cpp
@@ -70,7 +70,7 @@ getZygoteProcessName(void)
assert(fd >= 0);
len = read(fd, buf, size - 1);
close(fd);
- path.truncate(len);
+ path.truncate();
return path;
}
More information about the apitrace
mailing list