From: Ian Campbell Date: Mon, 13 Jul 2015 12:31:23 +0000 (+0100) Subject: tools: libxl: Handle failure to create qemu dm logfile X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~2826 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=e9d3a859977913704605e0fd87887451b12d4722;p=xen.git 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. Reported-by: Russell Coker Signed-off-by: Ian Campbell Cc: 784880@bugs.debian.org Acked-by: Wei Liu --- diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index ad434f05ef..8ed2d2ed1d 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -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);