mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
Sanitize qemu monitor reads.
This commit is contained in:
parent
36c612b21c
commit
0e459cbdfb
@ -1,3 +1,7 @@
|
||||
Tue Dec 16 17:26:49 EST 2008 Cole Robinson <crobinso@redhat.com>
|
||||
|
||||
* src/qemu_driver.c: Sanitize qemu monitor reads.
|
||||
|
||||
Mon Dec 15 21:05:56 CET 2008 Guido Günther <agx@sigxcpu.org>
|
||||
|
||||
Add virAsprintf as safer asprintf helper
|
||||
|
@ -1198,7 +1198,23 @@ qemudMonitorCommand (const virDomainObjPtr vm,
|
||||
|
||||
/* Look for QEMU prompt to indicate completion */
|
||||
if (buf && ((tmp = strstr(buf, "\n(qemu) ")) != NULL)) {
|
||||
tmp[0] = '\0';
|
||||
char *commptr = NULL, *nlptr = NULL;
|
||||
|
||||
/* Preserve the newline */
|
||||
tmp[1] = '\0';
|
||||
|
||||
/* The monitor doesn't dump clean output after we have written to
|
||||
* it. Every character we write dumps a bunch of useless stuff,
|
||||
* so the result looks like "cXcoXcomXcommXcommaXcommanXcommand"
|
||||
* Try to throw away everything before the first full command
|
||||
* occurence, and inbetween the command and the newline starting
|
||||
* the response
|
||||
*/
|
||||
if ((commptr = strstr(buf, cmd)))
|
||||
memmove(buf, commptr, strlen(commptr)+1);
|
||||
if ((nlptr = strchr(buf, '\n')))
|
||||
memmove(buf+strlen(cmd), nlptr, strlen(nlptr)+1);
|
||||
|
||||
break;
|
||||
}
|
||||
pollagain:
|
||||
@ -2919,7 +2935,7 @@ static int qemudDomainChangeEjectableMedia(virConnectPtr conn,
|
||||
|
||||
if (qemudMonitorCommand(vm, cmd, &reply) < 0) {
|
||||
qemudReportError(conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
|
||||
"%s", _("cannot change cdrom media"));
|
||||
"%s", _("could not change cdrom media"));
|
||||
VIR_FREE(cmd);
|
||||
return -1;
|
||||
}
|
||||
@ -2930,7 +2946,7 @@ static int qemudDomainChangeEjectableMedia(virConnectPtr conn,
|
||||
DEBUG ("ejectable media change reply: %s", reply);
|
||||
if (strstr(reply, "\ndevice ")) {
|
||||
qemudReportError (conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
|
||||
"%s", _("changing cdrom media failed"));
|
||||
_("changing cdrom media failed: %s"), reply);
|
||||
VIR_FREE(reply);
|
||||
VIR_FREE(cmd);
|
||||
return -1;
|
||||
@ -3468,7 +3484,7 @@ qemudDomainBlockStats (virDomainPtr dom,
|
||||
* unlikely to be the name of a block device, we can use this
|
||||
* to detect if qemu supports the command.
|
||||
*/
|
||||
if (STRPREFIX (info, "info ")) {
|
||||
if (strstr(info, "\ninfo ")) {
|
||||
qemudReportError (dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT,
|
||||
"%s",
|
||||
_("'info blockstats' not supported by this qemu"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user