summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Lutomirski <luto@amacapital.net>2014-03-24 13:59:13 -0700
committerAndy Lutomirski <luto@amacapital.net>2014-03-24 13:59:13 -0700
commit254ef237418d36b0239afb134d91d3048f7ea9d1 (patch)
tree6d985610e69892094a062b230dcc6b807e1fbaf1
parentd92d6d30974c6545dffa3919ed9bd8460e3dff9a (diff)
downloadmisc-tests-254ef237418d36b0239afb134d91d3048f7ea9d1.tar.gz
dump-vdso: Add error handling
-rw-r--r--dump-vdso.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/dump-vdso.c b/dump-vdso.c
index 937c00c..dbd6439 100644
--- a/dump-vdso.c
+++ b/dump-vdso.c
@@ -1,19 +1,27 @@
#include <stdio.h>
#include <string.h>
-int
-main()
+int main()
{
FILE *maps;
void *vdso_begin, *vdso_end;
+ int found_vdso = 0;
maps = fopen("/proc/self/maps", "r");
char buf[1024];
while (fgets(buf, 1024, maps)) {
- if (strstr(buf, "[vdso]")) break;
+ if (strstr(buf, "[vdso]")) {
+ found_vdso = 1;
+ break;
+ }
}
fclose(maps);
+ if (!found_vdso) {
+ fprintf(stderr, "Could not find vdso mapping\n");
+ return 1;
+ }
+
sscanf(buf, "%p-%p", &vdso_begin, &vdso_end);
write(1, vdso_begin, vdso_end - vdso_begin);