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 <[email protected]>
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
--- block.c | 1 + 1 file changed, 1 insertion(+)
block.c +1 -0
@@ -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); }
Signature · 1 line
2.21.1
Alberto Garcia
Reviewed-byQuoted 6 lines · Philippe Mathieu-Daudé
bdrv_do_find_format()callsstrcmp()usingBlockDriver::format_nameas argument, which must not be NULL. Assert this field is not null when we register a block driver inbdrv_register().Reported-by Mansour Ahmadi <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Reviewed-by Alberto Garcia <[email protected]>
Berto
Max Reitz
AppliedQuoted 9 lines · Philippe Mathieu-Daudé
bdrv_do_find_format()callsstrcmp()usingBlockDriver::format_nameas argument, which must not be NULL. Assert this field is not null when we register a block driver inbdrv_register().Reported-by Mansour Ahmadi <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- block.c | 1 + 1 file changed, 1 insertion(+)
Thanks, applied to my block branch:
https://git.xanclic.moe/XanClic/qemu/commits/branch/block
Max