summaryrefslogtreecommitdiff
path: root/blkparse.c
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2011-12-16 13:36:56 -0600
committerJens Axboe <jaxboe@fusionio.com>2012-02-01 13:14:33 +0100
commitd324757e0f2cfc87ddcc2fea7e59d81cc8661f1c (patch)
tree4cd4290cd22445f018767d5590e04e43b4db20f7 /blkparse.c
parent62d712a7bb9cd4c8366d8228cf90ffa7b31b6eac (diff)
downloadblktrace-d324757e0f2cfc87ddcc2fea7e59d81cc8661f1c.tar.gz
blktrace-d324757e0f2cfc87ddcc2fea7e59d81cc8661f1c.tar.bz2
avoid string overflows
Several places using strcpy would benefit from strncpy for safety. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'blkparse.c')
-rw-r--r--blkparse.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/blkparse.c b/blkparse.c
index 80b3a71..b0b88c3 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -562,7 +562,9 @@ static struct process_pid_map *add_ppm_hash(pid_t pid, const char *name)
ppm = malloc(sizeof(*ppm));
memset(ppm, 0, sizeof(*ppm));
ppm->pid = pid;
- strcpy(ppm->comm, name);
+ memset(ppm->comm, 0, sizeof(ppm->comm));
+ strncpy(ppm->comm, name, sizeof(ppm->comm));
+ ppm->comm[sizeof(ppm->comm) - 1] = '\0';
ppm->hash_next = ppm_hash_table[hash_idx];
ppm_hash_table[hash_idx] = ppm;
}