diff options
author | Ian Jackson <ian.jackson@eu.citrix.com> | 2012-06-28 18:43:19 +0100 |
---|---|---|
committer | Ian Jackson <ian.jackson@eu.citrix.com> | 2012-06-28 18:43:19 +0100 |
commit | f0db674c643f8db29534b90ea9343e4dbddc2aac (patch) | |
tree | bae0e927d368a6589b4bc633742d563874fcf1cb /tools/libxc/xc_domain_save.c | |
parent | 0f8d5c6087c1da11519103fe21d405f22f3adc63 (diff) | |
download | xen-f0db674c643f8db29534b90ea9343e4dbddc2aac.tar.gz xen-f0db674c643f8db29534b90ea9343e4dbddc2aac.tar.bz2 xen-f0db674c643f8db29534b90ea9343e4dbddc2aac.zip |
libxc: Do not segfault if (e.g.) switch_qemu_logdirty fails
In xc_domain_save the local variable `ob' is initialised to NULL.
There are then various startup actions. Some of these `goto out' on
failure; for example the call to callbacks->switch_qemu_logdirty on
l.978. However, out is used both by success and error paths. So it
attempts (l.2043) to flush the current output buffer. If ob has not
yet been assigned a non-NULL value, this segfaults. So make the call
to outbuf_flush conditional on ob.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxc/xc_domain_save.c')
-rw-r--r-- | tools/libxc/xc_domain_save.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/libxc/xc_domain_save.c b/tools/libxc/xc_domain_save.c index fcc7718ecb..c359649edb 100644 --- a/tools/libxc/xc_domain_save.c +++ b/tools/libxc/xc_domain_save.c @@ -2040,7 +2040,7 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iter } /* Flush last write and discard cache for file. */ - if ( outbuf_flush(xch, ob, io_fd) < 0 ) { + if ( ob && outbuf_flush(xch, ob, io_fd) < 0 ) { PERROR("Error when flushing output buffer"); rc = 1; } |