summaryrefslogtreecommitdiff
path: root/blktrace.c
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2012-01-31 10:51:50 +0100
committerJens Axboe <axboe@kernel.dk>2012-01-31 10:51:50 +0100
commitd8365957edd930f13628ff473fd52501bd9c5dae (patch)
tree9a43facd29838e6053e5f4f8a6e9e4756a63178d /blktrace.c
parent8e8bb835e375bd8cf0f01debff61f6bf467bb1ed (diff)
downloadblktrace-d8365957edd930f13628ff473fd52501bd9c5dae.tar.gz
blktrace-d8365957edd930f13628ff473fd52501bd9c5dae.tar.bz2
Fix for realloc bug and wrong error logging
This patch fixes two bugs in blktrace. 1. realloc is called on a wrong memory address (glibc reports heap corruption if the user sends the output to a pipe, for example "blktrace /dev/sdc -o -"). 2. errno 0 is actually reported if debugfs is not mounted Mikulas Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'blktrace.c')
-rw-r--r--blktrace.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/blktrace.c b/blktrace.c
index 72866e2..b14daf2 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -1330,7 +1330,7 @@ static struct trace_buf *tb_combine(struct trace_buf *prev,
* the whole structures, as the other fields
* are "static".
*/
- prev = realloc(prev->buf, sizeof(*prev) + tot_len);
+ prev = realloc(prev, sizeof(*prev) + tot_len);
prev->buf = (void *)(prev + 1);
}
@@ -2155,12 +2155,17 @@ static int handle_args(int argc, char *argv[])
return 1;
}
- if (statfs(debugfs_path, &st) < 0 || st.f_type != (long)DEBUGFS_TYPE) {
+ if (statfs(debugfs_path, &st) < 0) {
fprintf(stderr, "Invalid debug path %s: %d/%s\n",
debugfs_path, errno, strerror(errno));
return 1;
}
+ if (st.f_type != (long)DEBUGFS_TYPE) {
+ fprintf(stderr, "Debugfs is not mounted at %s\n", debugfs_path);
+ return 1;
+ }
+
if (act_mask_tmp != 0)
act_mask = act_mask_tmp;