diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2012-01-31 10:51:50 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2012-01-31 10:51:50 +0100 |
commit | d8365957edd930f13628ff473fd52501bd9c5dae (patch) | |
tree | 9a43facd29838e6053e5f4f8a6e9e4756a63178d | |
parent | 8e8bb835e375bd8cf0f01debff61f6bf467bb1ed (diff) | |
download | blktrace-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>
-rw-r--r-- | blktrace.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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; |