From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36683) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrS4R-0001uj-1k for qemu-devel@nongnu.org; Fri, 13 Dec 2013 07:42:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VrS4M-0005gv-6A for qemu-devel@nongnu.org; Fri, 13 Dec 2013 07:42:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42680) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrS4L-0005gl-U3 for qemu-devel@nongnu.org; Fri, 13 Dec 2013 07:42:14 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rBDCgCSC029885 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 13 Dec 2013 07:42:13 -0500 Message-ID: <52AB00A3.7010901@redhat.com> Date: Fri, 13 Dec 2013 05:42:11 -0700 From: Eric Blake MIME-Version: 1.0 References: <1386929555-3374-1-git-send-email-kraxel@redhat.com> In-Reply-To: <1386929555-3374-1-git-send-email-kraxel@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="mj5pfnh0KEsj2GKSK2PSBr8exWLRf3pvB" Subject: Re: [Qemu-devel] [PATCH v4] inet_listen_opts: add error checking List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --mj5pfnh0KEsj2GKSK2PSBr8exWLRf3pvB Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 12/13/2013 03:12 AM, Gerd Hoffmann wrote: > Don't use atoi() function which doesn't detect errors, switch to > strtol and error out on failures. Also add a range check while > being at it. >=20 > [ v4: didn't commit buildfix. -ENOCOFFEE. sorry for the spam ] > [ v3: oops, v2 didn't build ] > [ v2: use parse_uint_full instead of strtol ] Patch changelog belongs... >=20 > Signed-off-by: Gerd Hoffmann > --- =2E..here. You can add a '---' separator in your commit message (and thu= s have two '---' lines in 'git send-email' output), if you still want to track the changelog in your commits (but remember to hoist your S-o-B when doing that). > util/qemu-sockets.c | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) >=20 > + if (port_offset) { > + unsigned long long baseport; > + if (parse_uint_full(port, &baseport, 10) < 0) { > + error_setg(errp, "can't convert to a number: %s", port); > + return -1; > + } > + if (baseport + port_offset > 65535) { > + error_setg(errp, "port %s out of range", port); error_setg() is still reporting on a bogus errno value at this point. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --mj5pfnh0KEsj2GKSK2PSBr8exWLRf3pvB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.15 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSqwCjAAoJEKeha0olJ0NqfacH/0nSMaiFWFAmdmNqSg5Uvo81 YnbwPoY4baIVoEEjPkhmUEykS9c7Py/CzaJvdEOM94NHplr9rYSpdGQ9or1gNrUN yNkz6GlbQN7Vw++0LHqtJfk2zsy/O4BqysX/PjF43PCrvZvevFkiWCCeqJlVRxEZ yZKXI3KArMGlPDCb8ut9wPqBYmdCpcY8qrFEfVQJ8+k/f8eT7Dnt4Hn3SB0llRdl zeO7G6Wug12SyC6zp60fkf0hA3Kgu4+mv7JvwrRBkznsVVTuax4kuWhJeUoYvd2v 3ozBmgEQCw3UAmS+PsjVtgaCZpKxIP3PIsdF1CWUHRfgJJD3DDebESydqDwF6LM= =iy5j -----END PGP SIGNATURE----- --mj5pfnh0KEsj2GKSK2PSBr8exWLRf3pvB--