mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
qemu-sockets: avoid strlen of NULL pointer
If the user wants to create a chardev of type socket but forgets to give a host= option, qemu_opt_get returns NULL. This NULL pointer is then fed into strlen a few lines below without a check which results in a segfault. This fixes it. Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
This commit is contained in:
committed by
Aurelien Jarno
parent
81bbe906c8
commit
e23a22e620
+2
-1
@@ -130,7 +130,8 @@ int inet_listen_opts(QemuOpts *opts, int port_offset)
|
||||
ai.ai_family = PF_UNSPEC;
|
||||
ai.ai_socktype = SOCK_STREAM;
|
||||
|
||||
if (qemu_opt_get(opts, "port") == NULL) {
|
||||
if ((qemu_opt_get(opts, "host") == NULL) ||
|
||||
(qemu_opt_get(opts, "port") == NULL)) {
|
||||
fprintf(stderr, "%s: host and/or port not specified\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user