Skip to contentSkip to conversation

opts: fix NULL pointer derefernce in get_opt_value

PATCH In review Mike Krinkin 3 participants 4 messages Jul 16, 2018 – Jul 17, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 opts: fix NULL pointer derefernce in get_opt_value

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.

---
 util/qemu-option.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
util/qemu-option.c +3 -1
index 19761e3eaf..834217fc75 100644
@@ -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;
Signature · 1 line
2.17.1
#1 lore raw
Quoted 4 lines · 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.

Quoted 8 lines

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.

---
 util/qemu-option.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

This problem is fixed in this:

https://lists.gnu.org/archive/html/qemu-devel/2018-06/msg01490.html

but it is still waiting for i386 maintainers to respond....

Regards,
Daniel

Signature · 3 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|
#2 lore raw
Quoted 14 lines · Daniel P. Berrange
Quoted 4 lines · 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.

Quoted 8 lines

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.

---
 util/qemu-option.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 6 lines

This problem is fixed in this:

https://lists.gnu.org/archive/html/qemu-devel/2018-06/msg01490.html

but it is still waiting for i386 maintainers to respond....

Thanks for the update, I searched through the archive briefly but didn't find this fix, sorry for the noise and please ignore this path.

Quoted 11 lines

Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/
:|
|: http://libvirt.org -o- http://virt-manager.org
:|
|: http://entangle-photo.org -o- http://search.cpan.org/~danberr/
:|

#3 lore raw
In reply to Daniel P. Berrange
Quoted 14 lines · Daniel P. Berrange
Quoted 4 lines · 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.

Quoted 8 lines

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.

---
 util/qemu-option.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 5 lines

This problem is fixed in this:

https://lists.gnu.org/archive/html/qemu-devel/2018-06/msg01490.html

but it is still waiting for i386 maintainers to respond....

Generally Kevin has looked at multiboot patches, but I'll merge these ones because he's on vacation. Thanks,

Paolo