diff options
author | Max Reitz <mreitz@redhat.com> | 2017-06-13 19:20:06 +0200 |
---|---|---|
committer | Max Reitz <mreitz@redhat.com> | 2017-06-26 14:54:46 +0200 |
commit | 05cc758a3dfc79488d0a8eb7f5830a41871e78d0 (patch) | |
tree | 28f70ee8318cfd620997a2f29136c027ff02fa67 /block/blkverify.c | |
parent | de81d72d3d13a19edf4d461be3b0f5a877be0234 (diff) |
blkverify: Catch bs->exact_filename overflow
The bs->exact_filename field may not be sufficient to store the full
blkverify node filename. In this case, we should not generate a filename
at all instead of an unusable one.
Cc: qemu-stable@nongnu.org
Reported-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-id: 20170613172006.19685-3-mreitz@redhat.com
Reviewed-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block/blkverify.c')
-rw-r--r-- | block/blkverify.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/block/blkverify.c b/block/blkverify.c index 6b0a603cf0..06369f9eac 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -301,10 +301,14 @@ static void blkverify_refresh_filename(BlockDriverState *bs, QDict *options) if (bs->file->bs->exact_filename[0] && s->test_file->bs->exact_filename[0]) { - snprintf(bs->exact_filename, sizeof(bs->exact_filename), - "blkverify:%s:%s", - bs->file->bs->exact_filename, - s->test_file->bs->exact_filename); + int ret = snprintf(bs->exact_filename, sizeof(bs->exact_filename), + "blkverify:%s:%s", + bs->file->bs->exact_filename, + s->test_file->bs->exact_filename); + if (ret >= sizeof(bs->exact_filename)) { + /* An overflow makes the filename unusable, so do not report any */ + bs->exact_filename[0] = 0; + } } } |