X-Git-Url: http://git.thejh.net/?p=tools.git;a=blobdiff_plain;f=tools%2Fstrscan.c;h=613319ac2adf6645b2c3b5ca4691d416000dcb96;hp=606096939759b6919074c47b3c2105d38188e781;hb=23dee97330ca19edf089e9399bdfb6bc78354a5f;hpb=60706164dfb67737ccd4b761818eabce887d4214 diff --git a/tools/strscan.c b/tools/strscan.c index 6060969..613319a 100644 --- a/tools/strscan.c +++ b/tools/strscan.c @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include #include #include @@ -31,11 +33,28 @@ int main(int argc, char **argv) { if (argc != 3) xperror("invocation: anondump ", 0); TPRINTF(maps_path, "/proc/%s/maps", argv[1]) char *maps = CHK_PTR(slurp_file(maps_path, NULL, JH_SLURP_NO_STAT), "unable to read /proc/$pid/maps", 1); + +/* + char argbuf[8192]; + size_t arglen = strlen(argv[2])*4; + for (int i=0; ib - mapping->a; char *copy = CHK_PTR(malloc(len), "malloc failed", 1); - if (pread(memfd, copy, len, (off_t)mapping->a) != (ssize_t)len) xperror("pread failed", 0); + ssize_t read_res; + size_t read_done = 0; +read_more:; + if ((read_res=pread(memfd, copy+read_done, len-read_done, (off_t)mapping->a-read_done)) != (ssize_t)len) { + if (read_res <= 0) { + fputs("warning: some read failed\n", stderr); + continue; + } + read_done += read_res; + goto read_more; + } size_t pos = 0; while (1) { char *ptr = memmem(copy + pos, len, argv[2], strlen(argv[2]));