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:
parent
81bbe906c8
commit
e23a22e620
@ -130,7 +130,8 @@ int inet_listen_opts(QemuOpts *opts, int port_offset)
|
|||||||
ai.ai_family = PF_UNSPEC;
|
ai.ai_family = PF_UNSPEC;
|
||||||
ai.ai_socktype = SOCK_STREAM;
|
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__);
|
fprintf(stderr, "%s: host and/or port not specified\n", __FUNCTION__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user