[libvirt] [PATCH] Fix latent buffer overflow in qemudOpenMonitorUnix.
by Chris Lalancette
Fix a possible latent bug in qemudOpenMonitorUnix(). If the pathname
to the monitor is very long (i.e. >= UNIX_MAX_PATH), then strncpy will
*not* place a final \0 on the string (see "man strncpy").
NULL terminate the buffer to ensure we don't run off the end.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/qemu_driver.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 9fcc07a..4f173b7 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -910,6 +910,7 @@ qemudOpenMonitorUnix(virConnectPtr conn,
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
strncpy(addr.sun_path, monitor, sizeof(addr.sun_path));
+ NUL_TERMINATE(addr.sun_path);
do {
ret = connect(monfd, (struct sockaddr *) &addr, sizeof(addr));
--
1.6.0.6
15 years, 3 months
[libvirt] [PATCH] Remove a stray semicolon in qemudDomainMigratePrepare2.
by Chris Lalancette
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/qemu_driver.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 83cbcf3..5f4b28b 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -6274,7 +6274,7 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
char migrateFrom [64];
const char *p;
virDomainEventPtr event = NULL;
- int ret = -1;;
+ int ret = -1;
int internalret;
*uri_out = NULL;
--
1.6.0.6
15 years, 3 months
[libvirt] [PATCH] Workaround for broken GCC in Debian Etch
by Maximilian Wilhelm
Hi again!
I missed one patch for working around a GCC bug in Debian Etch
regarding limit definitions.
Sorry for the unstripped git-format-patch outputs, I just realised
this after pressing send :(
(This seems to be not my day :))
Ciao
Max
--
Gib Dein Bestes. Dann übertriff Dich selbst!
15 years, 3 months
[libvirt] [PATCH] Remove ATTRIBUTE_UNUSED from flags to qemudDomainMigratePerform.
by Chris Lalancette
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/qemu_driver.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index eadb53f..9fcc07a 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -6424,7 +6424,7 @@ qemudDomainMigratePerform (virDomainPtr dom,
const char *cookie ATTRIBUTE_UNUSED,
int cookielen ATTRIBUTE_UNUSED,
const char *uri,
- unsigned long flags ATTRIBUTE_UNUSED,
+ unsigned long flags,
const char *dname ATTRIBUTE_UNUSED,
unsigned long resource)
{
--
1.6.0.6
15 years, 3 months
[libvirt] [PATCH] Add a comment about setting errors after qemudStartVMDaemon().
by Chris Lalancette
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/qemu_driver.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index fcfbfbc..eadb53f 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -6390,6 +6390,9 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
*/
snprintf (migrateFrom, sizeof (migrateFrom), "tcp:0.0.0.0:%d", this_port);
if (qemudStartVMDaemon (dconn, driver, vm, migrateFrom, -1) < 0) {
+ /* Note that we don't set an error here because qemudStartVMDaemon
+ * should have already done that.
+ */
if (!vm->persistent) {
virDomainRemoveInactive(&driver->domains, vm);
vm = NULL;
--
1.6.0.6
15 years, 3 months
[libvirt] [PATCH] Fix an erroneous debug error to KVM; it should read QEMU/KVM.
by Chris Lalancette
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/qemu_driver.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 5f4b28b..fcfbfbc 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -6321,7 +6321,7 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
*/
if (!STRPREFIX (uri_in, "tcp:")) {
qemudReportError (dconn, NULL, NULL, VIR_ERR_INVALID_ARG,
- "%s", _("only tcp URIs are supported for KVM migrations"));
+ "%s", _("only tcp URIs are supported for KVM/QEMU migrations"));
goto cleanup;
}
--
1.6.0.6
15 years, 3 months
[libvirt] [PATCH] Convert a few stray users of free() in libvirt.c to VIR_FREE().
by Chris Lalancette
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/libvirt.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index 167359f..9fd864d 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -3020,7 +3020,7 @@ virDomainMigrate (virDomainPtr domain,
ret = dconn->driver->domainMigratePrepare2
(dconn, &cookie, &cookielen, uri, &uri_out, flags, dname,
bandwidth, dom_xml);
- free (dom_xml);
+ VIR_FREE (dom_xml);
if (ret == -1) goto done;
if (uri == NULL && uri_out == NULL) {
virLibConnError (conn, VIR_ERR_INTERNAL_ERROR,
@@ -3062,8 +3062,8 @@ virDomainMigrate (virDomainPtr domain,
}
done:
- free (uri_out);
- free (cookie);
+ VIR_FREE (uri_out);
+ VIR_FREE (cookie);
return ddomain;
error:
--
1.6.0.6
15 years, 3 months
[libvirt] [PATCH] Use virGetHostname instead of gethostname.
by Chris Lalancette
Fix up qemudDomainMigratePrepare2 to use virGetHostname instead of
gethostname. Besides the fact that virGetHostname is far more clever,
there was a latent bug in the handling that could cause a buffer overflow
on a very long hostname.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/qemu_driver.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index cee2164..83cbcf3 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -6270,11 +6270,12 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
virDomainDefPtr def = NULL;
virDomainObjPtr vm = NULL;
int this_port;
- char hostname [HOST_NAME_MAX+1];
+ char *hostname;
char migrateFrom [64];
const char *p;
virDomainEventPtr event = NULL;
int ret = -1;;
+ int internalret;
*uri_out = NULL;
@@ -6300,14 +6301,16 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
if (port == QEMUD_MIGRATION_NUM_PORTS) port = 0;
/* Get hostname */
- if (gethostname (hostname, HOST_NAME_MAX+1) == -1) {
+ if ((hostname = virGetHostname()) == NULL) {
virReportSystemError (dconn, errno,
"%s", _("failed to determine host name"));
goto cleanup;
}
/* Caller frees */
- if (virAsprintf(uri_out, "tcp:%s:%d", hostname, this_port) < 0) {
+ internalret = virAsprintf(uri_out, "tcp:%s:%d", hostname, this_port);
+ VIR_FREE(hostname);
+ if (internalret < 0) {
virReportOOMError (dconn);
goto cleanup;
}
--
1.6.0.6
15 years, 3 months
[libvirt] [PATCH] Fix up a minor indentation issue with virDomainMigratePrepare.
by Chris Lalancette
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/libvirt.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index 7ecf1ec..167359f 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -3078,13 +3078,13 @@ error:
*/
int
virDomainMigratePrepare (virConnectPtr dconn,
- char **cookie,
- int *cookielen,
- const char *uri_in,
- char **uri_out,
- unsigned long flags,
- const char *dname,
- unsigned long bandwidth)
+ char **cookie,
+ int *cookielen,
+ const char *uri_in,
+ char **uri_out,
+ unsigned long flags,
+ const char *dname,
+ unsigned long bandwidth)
{
VIR_DEBUG("dconn=%p, cookie=%p, cookielen=%p, uri_in=%s, uri_out=%p, "
"flags=%lu, dname=%s, bandwidth=%lu", dconn, cookie, cookielen,
--
1.6.0.6
15 years, 3 months