block: Assert BlockDriver::format_name is not NULL

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>
This commit is contained in:
Philippe Mathieu-Daudé 2020-03-18 23:22:35 +01:00 committed by Max Reitz
parent 71eaec2e8c
commit a15f08dcee

View File

@ -363,6 +363,7 @@ char *bdrv_get_full_backing_filename(BlockDriverState *bs, Error **errp)
void bdrv_register(BlockDriver *bdrv) void bdrv_register(BlockDriver *bdrv)
{ {
assert(bdrv->format_name);
QLIST_INSERT_HEAD(&bdrv_drivers, bdrv, list); QLIST_INSERT_HEAD(&bdrv_drivers, bdrv, list);
} }