summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2011-07-13 13:35:20 -0700
committerColin Cross <ccross@android.com>2011-07-13 13:35:20 -0700
commit6620157c0f583c4c7a59d1d595589dbb2b3ae4b5 (patch)
tree670716de0a80b3702243bb1b5fd7a78db5fd46e0
parent5923f33ed7cf186ceac3541987efcc32beb29ab9 (diff)
downloadextras-6620157c0f583c4c7a59d1d595589dbb2b3ae4b5.tar.gz
Handle EOF when reading /proc/<pid>/pagemap
Instead of handling maps with the name "[vectors]" specially, silently ignore EOF when reading from /proc/<pid>/pagemap, which occurs any time a a mapping is outside of the userspace range. Change-Id: I674ade1eab6fd7732c6d9e120d0750cca5415b25
-rw-r--r--libpagemap/pm_process.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/libpagemap/pm_process.c b/libpagemap/pm_process.c
index 0f54b481..b3c077ee 100644
--- a/libpagemap/pm_process.c
+++ b/libpagemap/pm_process.c
@@ -116,7 +116,13 @@ int pm_process_pagemap_range(pm_process_t *proc,
return error;
}
error = read(proc->pagemap_fd, (char*)range, numpages * sizeof(uint64_t));
- if (error < numpages * sizeof(uint64_t)) {
+ if (error == 0) {
+ /* EOF, mapping is not in userspace mapping range (probably vectors) */
+ *len = 0;
+ free(range);
+ *range_out = NULL;
+ return 0;
+ } else if (error < 0 || (error > 0 && error < numpages * sizeof(uint64_t))) {
error = (error < 0) ? errno : -1;
free(range);
return error;
@@ -258,9 +264,6 @@ static int read_maps(pm_process_t *proc) {
sscanf(line, "%lx-%lx %s %lx %*s %*d %" S(MAX_LINE) "s",
&map->start, &map->end, perms, &map->offset, name);
- if (!strcmp(name, "[vectors]"))
- continue;
-
map->name = malloc(strlen(name) + 1);
if (!map->name) {
error = errno;