raw: Fix segfault in raw_create when opts is NULL
PATCH 1/1 raw: Fix segfault in raw_create when opts is NULL
Reported-by Milos Vyletel <[email protected]>
Signed-off-by Fam Zheng <[email protected]>
--- block/raw-posix.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
block/raw-posix.c +4 -2
@@ -1282,8 +1282,10 @@ static int raw_create(const char *filename, QemuOpts *opts, Error **errp)strstart (filename,"file:" , &filename);/* Read out options */ - total_size = -qemu_opt_get_size_del (opts,BLOCK_OPT_SIZE ,0 ) /BDRV_SECTOR_SIZE ; +if (opts) { + total_size = +qemu_opt_get_size_del (opts,BLOCK_OPT_SIZE ,0 ) /BDRV_SECTOR_SIZE ; + } fd =qemu_open (filename,O_WRONLY |O_CREAT |O_TRUNC |O_BINARY ,0644 );
Signature · 1 line
2.0.0
Quoted 6 lines · Fam Zheng
Reported-by Milos Vyletel <[email protected]>Signed-off-by Fam Zheng <[email protected]>--- block/raw-posix.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Chunyan's solution looks better:
https://lists.gnu.org/archive/html/qemu-devel/2014-06/msg04104.html
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org