libxl: Fix uninitialized pointer when passing an empty cdrom
PATCH 1/1 libxl: Fix uninitialized pointer when passing an empty cdrom
Commit 3fec17d4bb56567d139d7806392f4d8702d3f6a7 introduced a bug where an empty cdrom would cause target_path to be uninitialized. Initialize target_path to NULL instead.
The other option here would have been to set target_path to NULL only on the LIBXL_DISK_FORMAT_EMPTY path. That would potentially enable the compiler to catch future uninitialized paths, rather than having those paths (potentially) dereference a NULL pointer. But given that a bunch of our compilers failed to catch *this* uninitialized path, setting it to NULL at declaration seems the safer option for now.
---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Andrew Cooper <[email protected]>
--- tools/libxl/libxl_dm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/libxl_dm.c +1 -1
@@ -1307,7 +1307,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,libxl__device_disk_dev_number (disks[i].vdev, &disk, &part);const char *format;char *drive; -const char *target_path; +const char *target_path =NULL ;int colo_mode;if (dev_number ==-1 ) {
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 11 lines · George Dunlap
Commit
3fec17d4bb56567d139d7806392f4d8702d3f6a7introduced a bug where an empty cdrom would causetarget_pathto be uninitialized. Initializetarget_pathto NULL instead.The other option here would have been to set
target_pathto NULL only on theLIBXL_DISK_FORMAT_EMPTYpath. That would potentially enable the compiler to catch future uninitialized paths, rather than having those paths (potentially) dereference a NULL pointer. But given that a bunch of our compilers failed to catch *this* uninitialized path, setting it to NULL at declaration seems the safer option for now.
Quoted 2 lines
Reported-by Andrew Cooper <[email protected]>Signed-off-by George Dunlap <[email protected]>
This looks like it will work. Reviewed-by: Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Andrew Cooper writes ("Re: [PATCH 1/1] libxl: Fix uninitialized pointer when passing an empty cdrom"):
Quoted 11 lines · George Dunlap
Quoted 10 lines
Commit
3fec17d4bb56567d139d7806392f4d8702d3f6a7introduced a bug where an empty cdrom would causetarget_pathto be uninitialized. Initializetarget_pathto NULL instead.The other option here would have been to set
target_pathto NULL only on theLIBXL_DISK_FORMAT_EMPTYpath. That would potentially enable the compiler to catch future uninitialized paths, rather than having those paths (potentially) dereference a NULL pointer. But given that a bunch of our compilers failed to catch *this* uninitialized path, setting it to NULL at declaration seems the safer option for now.
This reasoning is plausible.
Quoted 5 lines
Quoted 2 lines
Reported-by Andrew Cooper <[email protected]>Signed-off-by George Dunlap <[email protected]>This looks like it will work. Reviewed-by: Andrew Cooper <[email protected]>
Thanks. Queued.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel