qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] opts: fix NULL pointer derefernce in get_opt_value
@ 2018-07-16 17:41 Mike Krinkin
  2018-07-16 18:47 ` Daniel P. Berrange
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Krinkin @ 2018-07-16 17:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, berrange, pbonzini, qemu-trivial, Mike Krinkin

The value argument can be NULL, for example, in hw/i386/multiboot.c
in the load_multiboot function get_opt_value is explicitly called
with NULL as the second argument.

The problem was introduced in commit 950c4e6c94b1 ("opts: don't
silently truncate long option values"). This change fixes the
problem by adding a check whether the value is NULL or not.

Signed-off-by: Mike Krinkin <krinkin.m.u@gmail.com>
---
 util/qemu-option.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/util/qemu-option.c b/util/qemu-option.c
index 19761e3eaf..834217fc75 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -75,7 +75,9 @@ const char *get_opt_value(const char *p, char **value)
     size_t capacity = 0, length;
     const char *offset;
 
-    *value = NULL;
+    if (value) {
+        *value = NULL;
+    }
     while (1) {
         offset = qemu_strchrnul(p, ',');
         length = offset - p;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-07-17 10:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-16 17:41 [Qemu-devel] [PATCH] opts: fix NULL pointer derefernce in get_opt_value Mike Krinkin
2018-07-16 18:47 ` Daniel P. Berrange
2018-07-16 18:50   ` Mike Krinkin
2018-07-17 10:36   ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).