[libvirt] [PATCH v2] qemu: Fixing uninitialised variable inside virQEMUDriverConfigLoadFile.

Julio Faracco posted 1 patch 18 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20180611203533.1481-1-jcfaracco@gmail.com
Test syntax-check passed
src/qemu/qemu_conf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

[libvirt] [PATCH v2] qemu: Fixing uninitialised variable inside virQEMUDriverConfigLoadFile.

Posted by Julio Faracco 18 weeks ago
Since virConfGetValueBool() can return earlier, the parameter 'value'
might be not initialised properly inside this method. Another proof:
Valgrind is returning this error during the libvirtd daemon startup:

==16199== Conditional jump or move depends on uninitialised value(s)
==16199==    at 0x27FFFEF4: virQEMUDriverConfigLoadFile (qemu_conf.c:809)
==16199==    by 0x2807665C: qemuStateInitialize (qemu_driver.c:654)
==16199==    by 0x5535428: virStateInitialize (libvirt.c:662)
==16199==    by 0x12AED8: daemonRunStateInit (remote_daemon.c:802)
==16199==    by 0x536DE18: virThreadHelper (virthread.c:206)
==16199==    by 0x6CB36DA: start_thread (pthread_create.c:463)
==16199==    by 0x6FEC88E: clone (clone.S:95)

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
---
 src/qemu/qemu_conf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index f079ae3221..a4f545ef92 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -804,9 +804,9 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
         goto cleanup;
     if (virConfGetValueBool(conf, "clear_emulator_capabilities", &cfg->clearEmulatorCapabilities) < 0)
         goto cleanup;
-    if (virConfGetValueBool(conf, "allow_disk_format_probing", &tmp) < 0)
+    if ((rv = virConfGetValueBool(conf, "allow_disk_format_probing", &tmp)) < 0)
         goto cleanup;
-    if (tmp) {
+    if (rv == 1 && tmp) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("allow_disk_format_probing is no longer supported"));
         goto cleanup;
-- 
2.17.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v2] qemu: Fixing uninitialised variable inside virQEMUDriverConfigLoadFile.

Posted by Ján Tomko 18 weeks ago
To save precious space in the commit summary:
s/Fixing/fix/
s/inside/in/

And most importantly, I deleted the period at the end.

On Mon, Jun 11, 2018 at 05:35:33PM -0300, Julio Faracco wrote:
>Since virConfGetValueBool() can return earlier, the parameter 'value'
>might be not initialised properly inside this method. Another proof:
>Valgrind is returning this error during the libvirtd daemon startup:
>
>==16199== Conditional jump or move depends on uninitialised value(s)
>==16199==    at 0x27FFFEF4: virQEMUDriverConfigLoadFile (qemu_conf.c:809)
>==16199==    by 0x2807665C: qemuStateInitialize (qemu_driver.c:654)
>==16199==    by 0x5535428: virStateInitialize (libvirt.c:662)
>==16199==    by 0x12AED8: daemonRunStateInit (remote_daemon.c:802)
>==16199==    by 0x536DE18: virThreadHelper (virthread.c:206)
>==16199==    by 0x6CB36DA: start_thread (pthread_create.c:463)
>==16199==    by 0x6FEC88E: clone (clone.S:95)
>
>Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
>---
> src/qemu/qemu_conf.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>

Reviewed-by: J�n Tomko <jtomko@redhat.com>

And pushed.

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list