All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Krinkin <krinkin.m.u@gmail.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com, berrange@redhat.com, pbonzini@redhat.com,
	qemu-trivial@nongnu.org, Mike Krinkin <krinkin.m.u@gmail.com>
Subject: [Qemu-trivial] [PATCH] opts: fix NULL pointer derefernce in get_opt_value
Date: Mon, 16 Jul 2018 18:41:46 +0100	[thread overview]
Message-ID: <20180716174146.19845-1-krinkin.m.u@gmail.com> (raw)

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



WARNING: multiple messages have this Message-ID (diff)
From: Mike Krinkin <krinkin.m.u@gmail.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com, berrange@redhat.com, pbonzini@redhat.com,
	qemu-trivial@nongnu.org, Mike Krinkin <krinkin.m.u@gmail.com>
Subject: [Qemu-devel] [PATCH] opts: fix NULL pointer derefernce in get_opt_value
Date: Mon, 16 Jul 2018 18:41:46 +0100	[thread overview]
Message-ID: <20180716174146.19845-1-krinkin.m.u@gmail.com> (raw)

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

             reply	other threads:[~2018-07-16 18:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-16 17:41 Mike Krinkin [this message]
2018-07-16 17:41 ` [Qemu-devel] [PATCH] opts: fix NULL pointer derefernce in get_opt_value Mike Krinkin
2018-07-16 18:47 ` [Qemu-trivial] " Daniel P. Berrange
2018-07-16 18:47   ` [Qemu-devel] " Daniel P. Berrange
2018-07-16 18:50   ` [Qemu-trivial] " Mike Krinkin
2018-07-16 18:50     ` [Qemu-devel] " Mike Krinkin
2018-07-17 10:36   ` [Qemu-trivial] " Paolo Bonzini
2018-07-17 10:36     ` [Qemu-devel] " Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180716174146.19845-1-krinkin.m.u@gmail.com \
    --to=krinkin.m.u@gmail.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.