* [Qemu-devel] [PATCH] slirp: Clean up net_slirp_hostfwd_remove()'s use of get_str_sep()
@ 2011-11-16 14:45 Markus Armbruster
2011-11-18 12:42 ` Jan Kiszka
2011-11-18 13:53 ` Stefan Hajnoczi
0 siblings, 2 replies; 3+ messages in thread
From: Markus Armbruster @ 2011-11-16 14:45 UTC (permalink / raw)
To: qemu-devel; +Cc: jan.kiszka
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().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
net/slirp.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/net/slirp.c b/net/slirp.c
index c6cda5d..6646ecb 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -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;
--
1.7.6.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] slirp: Clean up net_slirp_hostfwd_remove()'s use of get_str_sep()
2011-11-16 14:45 [Qemu-devel] [PATCH] slirp: Clean up net_slirp_hostfwd_remove()'s use of get_str_sep() Markus Armbruster
@ 2011-11-18 12:42 ` Jan Kiszka
2011-11-18 13:53 ` Stefan Hajnoczi
1 sibling, 0 replies; 3+ messages in thread
From: Jan Kiszka @ 2011-11-18 12:42 UTC (permalink / raw)
To: Markus Armbruster, Stefan Hajnoczi; +Cc: qemu-trivial, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1515 bytes --]
On 2011-11-16 12:45, Markus Armbruster wrote:
> 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().
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Jan Kiszka <jan.kiszka@siemens.com>
Stefan, can you take this? My slirp queue not fully "operative" ATM down
here in Brazil.
Thanks,
Jan
> ---
> net/slirp.c | 9 ++++-----
> 1 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/net/slirp.c b/net/slirp.c
> index c6cda5d..6646ecb 100644
> --- a/net/slirp.c
> +++ b/net/slirp.c
> @@ -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;
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] slirp: Clean up net_slirp_hostfwd_remove()'s use of get_str_sep()
2011-11-16 14:45 [Qemu-devel] [PATCH] slirp: Clean up net_slirp_hostfwd_remove()'s use of get_str_sep() Markus Armbruster
2011-11-18 12:42 ` Jan Kiszka
@ 2011-11-18 13:53 ` Stefan Hajnoczi
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2011-11-18 13:53 UTC (permalink / raw)
To: Markus Armbruster; +Cc: jan.kiszka, qemu-devel
On Wed, Nov 16, 2011 at 03:45:59PM +0100, Markus Armbruster wrote:
> 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().
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
> net/slirp.c | 9 ++++-----
> 1 files changed, 4 insertions(+), 5 deletions(-)
Thanks, applied to the trivial patches -next tree:
http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/trivial-patches-next
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-11-18 15:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-16 14:45 [Qemu-devel] [PATCH] slirp: Clean up net_slirp_hostfwd_remove()'s use of get_str_sep() Markus Armbruster
2011-11-18 12:42 ` Jan Kiszka
2011-11-18 13:53 ` Stefan Hajnoczi
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.