From: Jan Kiszka <jan.kiszka@web.de>
To: Markus Armbruster <armbru@redhat.com>,
Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Cc: qemu-trivial <qemu-trivial@nongnu.org>, qemu-devel@nongnu.org
Subject: Re: [Qemu-trivial] [PATCH] slirp: Clean up net_slirp_hostfwd_remove()'s use of get_str_sep()
Date: Fri, 18 Nov 2011 10:42:48 -0200 [thread overview]
Message-ID: <4EC652C8.4080903@web.de> (raw)
In-Reply-To: <1321454759-19508-1-git-send-email-armbru@redhat.com>
[-- 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 --]
WARNING: multiple messages have this Message-ID (diff)
From: Jan Kiszka <jan.kiszka@web.de>
To: Markus Armbruster <armbru@redhat.com>,
Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Cc: qemu-trivial <qemu-trivial@nongnu.org>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] slirp: Clean up net_slirp_hostfwd_remove()'s use of get_str_sep()
Date: Fri, 18 Nov 2011 10:42:48 -0200 [thread overview]
Message-ID: <4EC652C8.4080903@web.de> (raw)
In-Reply-To: <1321454759-19508-1-git-send-email-armbru@redhat.com>
[-- 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 --]
next prev parent reply other threads:[~2011-11-18 12:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2011-11-18 12:42 ` Jan Kiszka
2011-11-18 13:53 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EC652C8.4080903@web.de \
--to=jan.kiszka@web.de \
--cc=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=stefanha@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.