[PATCH-for-5.0] block: Assert BlockDriver::format_name is not NULL

Philippe Mathieu-Daudé posted 1 patch 5 years, 8 months ago
Test docker-mingw@fedora passed
Test docker-quick@centos7 passed
Test checkpatch passed
Test FreeBSD passed
Test asan passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20200318222235.23856-1-philmd@redhat.com
Maintainers: Max Reitz <mreitz@redhat.com>, Kevin Wolf <kwolf@redhat.com>
block.c | 1 +
1 file changed, 1 insertion(+)
[PATCH-for-5.0] block: Assert BlockDriver::format_name is not NULL
Posted by Philippe Mathieu-Daudé 5 years, 8 months ago
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>
---
 block.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/block.c b/block.c
index a2542c977b..6b984dc883 100644
--- 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);
 }
 
-- 
2.21.1


Re: [PATCH-for-5.0] block: Assert BlockDriver::format_name is not NULL
Posted by Alberto Garcia 5 years, 7 months ago
On Wed 18 Mar 2020 11:22:35 PM CET, Philippe Mathieu-Daudé wrote:
> 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>

Reviewed-by: Alberto Garcia <berto@igalia.com>

Berto

Re: [PATCH-for-5.0] block: Assert BlockDriver::format_name is not NULL
Posted by Max Reitz 5 years, 7 months ago
On 18.03.20 23:22, Philippe Mathieu-Daudé wrote:
> 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>
> ---
>  block.c | 1 +
>  1 file changed, 1 insertion(+)

Thanks, applied to my block branch:

https://git.xanclic.moe/XanClic/qemu/commits/branch/block

Max