[libvirt] [PATCH v2] qemuTestDriverInit: fill driver with zeroes

In the commit aea47e48c473a we have fixed a single pointer within driver structure. Since all callers pass statically allocated driver on stack other pointers within driver may contain random values too. Before touching it lets overwrite it with zeroes and thus fix all dangling pointers. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- diff to v1: -Jirka's review worked in tests/testutilsqemu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index f2eacdd..ae69a18 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -555,11 +555,11 @@ int qemuTestCapsCacheInsert(virQEMUCapsCachePtr cache, const char *binary, int qemuTestDriverInit(virQEMUDriver *driver) { + memset(driver, 0, sizeof(*driver)); + if (virMutexInit(&driver->lock) < 0) return -1; - driver->securityManager = NULL; - driver->config = virQEMUDriverConfigNew(false); if (!driver->config) goto error; -- 2.4.10

On Mon, Jan 18, 2016 at 11:40:49 +0100, Michal Privoznik wrote:
In the commit aea47e48c473a we have fixed a single pointer within driver structure. Since all callers pass statically allocated driver on stack other pointers within driver may contain random values too. Before touching it lets overwrite it with zeroes and thus fix all dangling pointers.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> ---
diff to v1: -Jirka's review worked in
tests/testutilsqemu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index f2eacdd..ae69a18 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -555,11 +555,11 @@ int qemuTestCapsCacheInsert(virQEMUCapsCachePtr cache, const char *binary,
int qemuTestDriverInit(virQEMUDriver *driver) { + memset(driver, 0, sizeof(*driver)); + if (virMutexInit(&driver->lock) < 0) return -1;
- driver->securityManager = NULL; - driver->config = virQEMUDriverConfigNew(false); if (!driver->config) goto error;
ACK Jirka

On Mon, Jan 18, 2016 at 11:40:49AM +0100, Michal Privoznik wrote:
In the commit aea47e48c473a we have fixed a single pointer within driver structure. Since all callers pass statically allocated driver on stack other pointers within driver may contain random values too. Before touching it lets overwrite it with zeroes and thus fix all dangling pointers.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> ---
diff to v1: -Jirka's review worked in
That had to be hard ;) ACK.
participants (3)
-
Jiri Denemark
-
Martin Kletzander
-
Michal Privoznik