tools: libxl: Handle failure to create qemu dm logfile
PATCH 1/1 tools: libxl: Handle failure to create qemu dm logfile
If libxl_create_logfile fails for some reason then libxl__create_qemu_logfile previously just carried on and dereferenced the uninitialised logfile.
Check for the error from libxl_create_logfile, which has already logged for us.
This was reported as Debian bug #784880.
---
Should be backported.
--- tools/libxl/libxl_dm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/libxl/libxl_dm.c +4 -2
@@ -46,9 +46,11 @@ static const char *qemu_xen_path(libxl__gc *gc)static int libxl__create_qemu_logfile (libxl__gc *gc,char *name) {char *logfile; -int logfile_w; +int rc, logfile_w; + + rc =libxl_create_logfile (CTX , name, &logfile); +if (rc)return rc; -libxl_create_logfile (CTX , name, &logfile); logfile_w =open (logfile,O_WRONLY |O_CREAT |O_APPEND ,0644 );free (logfile);
Signature · 1 line
2.1.4
Quoted 4 lines · Ian Campbell
If
libxl_create_logfilefails for some reason thenlibxl__create_qemu_logfilepreviously just carried on and dereferenced the uninitialised logfile.
Quoted 8 lines
Check for the error from
libxl_create_logfile, which has already logged for us.This was reported as Debian bug #784880.
Reported-by Russell Coker <[email protected]>Signed-off-by Ian Campbell <[email protected]>
Quoted 26 lines
---
Should be backported.--- tools/libxl/libxl_dm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)tools/libxl/libxl_dm.c +4
-2@@ -46,9 +46,11 @@ static const char *qemu_xen_path(libxl__gc *gc)static int libxl__create_qemu_logfile (libxl__gc *gc,char *name) {char *logfile; -int logfile_w; +int rc, logfile_w; + + rc =libxl_create_logfile (CTX , name, &logfile); +if (rc)return rc; -libxl_create_logfile (CTX , name, &logfile); logfile_w =open (logfile,O_WRONLY |O_CREAT |O_APPEND ,0644 );free (logfile);Signature · 1 line
2.1.4
Ian Campbell
AppliedQuoted 8 lines · Wei Liu
Quoted 7 lines · Ian Campbell
If
libxl_create_logfilefails for some reason thenlibxl__create_qemu_logfilepreviously just carried on and dereferenced the uninitialised logfile.Check for the error from
libxl_create_logfile, which has already logged for us.
Quoted 7 lines
Quoted 5 lines
This was reported as Debian bug #784880.
Reported-by Russell Coker <[email protected]>Signed-off-by Ian Campbell <[email protected]>Acked-by Wei Liu <[email protected]>
Applied, thanks.
Ian, please:
Quoted 26 lines
Quoted 26 lines
Should be backported.
--- tools/libxl/libxl_dm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)tools/libxl/libxl_dm.c +4
-2@@ -46,9 +46,11 @@ static const char *qemu_xen_path(libxl__gc *gc)static int libxl__create_qemu_logfile (libxl__gc *gc,char *name) {char *logfile; -int logfile_w; +int rc, logfile_w; + + rc =libxl_create_logfile (CTX , name, &logfile); +if (rc)return rc; -libxl_create_logfile (CTX , name, &logfile); logfile_w =open (logfile,O_WRONLY |O_CREAT |O_APPEND ,0644 );free (logfile);Signature · 1 line
2.1.4