]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
block: Assert BlockDriver::format_name is not NULL
authorPhilippe Mathieu-Daudé <philmd@redhat.com>
Wed, 18 Mar 2020 22:22:35 +0000 (23:22 +0100)
committerMax Reitz <mreitz@redhat.com>
Tue, 24 Mar 2020 10:41:46 +0000 (11:41 +0100)
bdrv_do_find_format() calls strcmp() using BlockDriver::format_name
as argument, which must not be NULL. Assert this field is not null
when we register a block driver in bdrv_register().

Reported-by: Mansour Ahmadi <ManSoSec@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200318222235.23856-1-philmd@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
block.c

diff --git a/block.c b/block.c
index a2542c977b91a7e0c079d720f6877565a4170fc7..6b984dc883e27855a5f552c0700d255f3ff603de 100644 (file)
--- a/block.c
+++ b/block.c
@@ -363,6 +363,7 @@ char *bdrv_get_full_backing_filename(BlockDriverState *bs, Error **errp)
 
 void bdrv_register(BlockDriver *bdrv)
 {
+    assert(bdrv->format_name);
     QLIST_INSERT_HEAD(&bdrv_drivers, bdrv, list);
 }