summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-10-21 20:45:23 +0300
committerJari Vetoniemi <mailroxas@gmail.com>2018-10-21 21:51:56 +0300
commit04646db1bf7dee24d6063d61fc320e896ba36941 (patch)
treebbf4d0aa8a4b6e2a385b058c88b50618f631feb3
parent304bc20a6489309bfb28feebfa02777b1552334b (diff)
Make for_each_line_in_file work with non \n stuff
-rwxr-xr-xcontrib/brute-map.bash2
-rw-r--r--src/util.h4
2 files changed, 5 insertions, 1 deletions
diff --git a/contrib/brute-map.bash b/contrib/brute-map.bash
index a05e915..3ec1e52 100755
--- a/contrib/brute-map.bash
+++ b/contrib/brute-map.bash
@@ -5,7 +5,7 @@
while read -r region; do
offset=$(printf '%d' "0x$(awk '{print $3}' <<<"$region")")
if ((offset == 0)); then
- offset=$(binsearch <(ptrace-region-rw "$1" read <(printf '%s\n' "$region") | bintrim) first $3 < "$2" 2>/dev/null)
+ offset=$(binsearch <(ptrace-region-rw "$1" read <(printf '%s' "$region") | bintrim) first $3 < "$2" 2>/dev/null)
if [[ -n "$offset" ]]; then
hex=$(printf '%.8x' "$offset")
awk '{printf "%s %s %s %s %s %s\n", $1, $2, "'"$hex"'", $4, $5, $6, $7}' <<<"$region"
diff --git a/src/util.h b/src/util.h
index 8dc2fb9..79a7e7e 100644
--- a/src/util.h
+++ b/src/util.h
@@ -49,5 +49,9 @@ for_each_line_in_file(FILE *f, void (*cb)(const char *line, void *data), void *d
memmove(buffer, buffer + ate, (written = written - ate));
} while ((read = fread(buffer + written, 1, allocated - written, f)));
+
+ if (written > 0)
+ cb(buffer, data);
+
free(buffer);
}