提交 e30e5eb6 编写于 作者: M Markus Armbruster 提交者: Stefan Hajnoczi

slirp: Clean up net_slirp_hostfwd_remove()'s use of get_str_sep()

get_str_sep() can fail, but net_slirp_hostfwd_remove() doesn't check.
Works, because it initializes buf[] to "", which get_str_sep() doesn't
touch when it fails.  Coverity doesn't like it, and neither do I.

Change it to work exactly like slirp_hostfwd().
Acked-by: NJan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
Signed-off-by: NStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
上级 40897c9c
......@@ -305,7 +305,7 @@ void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict)
{
struct in_addr host_addr = { .s_addr = INADDR_ANY };
int host_port;
char buf[256] = "";
char buf[256];
const char *src_str, *p;
SlirpState *s;
int is_udp = 0;
......@@ -325,11 +325,10 @@ void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict)
return;
}
if (!src_str || !src_str[0])
goto fail_syntax;
p = src_str;
get_str_sep(buf, sizeof(buf), &p, ':');
if (!p || get_str_sep(buf, sizeof(buf), &p, ':') < 0) {
goto fail_syntax;
}
if (!strcmp(buf, "tcp") || buf[0] == '\0') {
is_udp = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册