mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-09 09:14:57 +00:00
virsh: do not unlink NULL file
error:could not take a screenshot of xp ==6216== Syscall param unlink(pathname) points to unaddressable byte(s) ==6216== at 0x373A0D4937: unlink (syscall-template.S:82) ==6216== by 0x40FD73: cmdScreenshot (virsh.c:3070) ==6216== by 0x42BA0D: vshCommandRun (virsh.c:14920) ==6216== by 0x42EC97: main (virsh.c:16379) ==6216== Address 0x0 is not stack'd, malloc'd or (recently) free'd ==6216== error:Requested operation is not valid: domain is not running
This commit is contained in:
parent
30f555c6a8
commit
41bf4e721e
@ -3004,7 +3004,7 @@ cmdScreenshot(vshControl *ctl, const vshCmd *cmd)
|
|||||||
unsigned int screen = 0;
|
unsigned int screen = 0;
|
||||||
unsigned int flags = 0; /* currently unused */
|
unsigned int flags = 0; /* currently unused */
|
||||||
int ret = false;
|
int ret = false;
|
||||||
bool created = true;
|
bool created = false;
|
||||||
bool generated = false;
|
bool generated = false;
|
||||||
char *mime = NULL;
|
char *mime = NULL;
|
||||||
|
|
||||||
@ -3039,12 +3039,13 @@ cmdScreenshot(vshControl *ctl, const vshCmd *cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((fd = open(file, O_WRONLY|O_CREAT|O_EXCL, 0666)) < 0) {
|
if ((fd = open(file, O_WRONLY|O_CREAT|O_EXCL, 0666)) < 0) {
|
||||||
created = false;
|
|
||||||
if (errno != EEXIST ||
|
if (errno != EEXIST ||
|
||||||
(fd = open(file, O_WRONLY|O_TRUNC, 0666)) < 0) {
|
(fd = open(file, O_WRONLY|O_TRUNC, 0666)) < 0) {
|
||||||
vshError(ctl, _("cannot create file %s"), file);
|
vshError(ctl, _("cannot create file %s"), file);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
created = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virStreamRecvAll(st, vshStreamSink, &fd) < 0) {
|
if (virStreamRecvAll(st, vshStreamSink, &fd) < 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user