From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:36066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRNmc-0006o8-Bz for qemu-devel@nongnu.org; Fri, 18 Nov 2011 07:43:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RRNmX-0005ot-MM for qemu-devel@nongnu.org; Fri, 18 Nov 2011 07:43:06 -0500 Message-ID: <4EC652C8.4080903@web.de> Date: Fri, 18 Nov 2011 10:42:48 -0200 From: Jan Kiszka MIME-Version: 1.0 References: <1321454759-19508-1-git-send-email-armbru@redhat.com> In-Reply-To: <1321454759-19508-1-git-send-email-armbru@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig3F91A8B8BFA40457D40BA0A6" Subject: Re: [Qemu-devel] [PATCH] slirp: Clean up net_slirp_hostfwd_remove()'s use of get_str_sep() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , Stefan Hajnoczi Cc: qemu-trivial , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig3F91A8B8BFA40457D40BA0A6 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable 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. >=20 > Change it to work exactly like slirp_hostfwd(). >=20 > Signed-off-by: Markus Armbruster Acked-by: Jan Kiszka 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(-) >=20 > 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 Q= Dict *qdict) > { > struct in_addr host_addr =3D { .s_addr =3D INADDR_ANY }; > int host_port; > - char buf[256] =3D ""; > + char buf[256]; > const char *src_str, *p; > SlirpState *s; > int is_udp =3D 0; > @@ -325,11 +325,10 @@ void net_slirp_hostfwd_remove(Monitor *mon, const= QDict *qdict) > return; > } > =20 > - if (!src_str || !src_str[0]) > - goto fail_syntax; > - > p =3D src_str; > - get_str_sep(buf, sizeof(buf), &p, ':'); > + if (!p || get_str_sep(buf, sizeof(buf), &p, ':') < 0) { > + goto fail_syntax; > + } > =20 > if (!strcmp(buf, "tcp") || buf[0] =3D=3D '\0') { > is_udp =3D 0; --------------enig3F91A8B8BFA40457D40BA0A6 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk7GUsgACgkQitSsb3rl5xRNGQCdGaFIqmk/sfjIbTwjYbS2qi29 v50AnjL3Y+jVRdVhpk/dGArzAKDrq8u9 =t5oC -----END PGP SIGNATURE----- --------------enig3F91A8B8BFA40457D40BA0A6--