qemu-trivial.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Re: [Qemu-trivial] [PATCH] slirp: Clean up net_slirp_hostfwd_remove()'s use of get_str_sep()
       [not found] <1321454759-19508-1-git-send-email-armbru@redhat.com>
@ 2011-11-18 12:42 ` Jan Kiszka
  0 siblings, 0 replies; only message 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] only message in thread

only message in thread, other threads:[~2011-11-18 12:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1321454759-19508-1-git-send-email-armbru@redhat.com>
2011-11-18 12:42 ` [Qemu-trivial] [PATCH] slirp: Clean up net_slirp_hostfwd_remove()'s use of get_str_sep() Jan Kiszka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).