From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50158) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzTD9-00082M-CA for qemu-devel@nongnu.org; Tue, 24 Jun 2014 12:04:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WzTD4-0002u4-Bs for qemu-devel@nongnu.org; Tue, 24 Jun 2014 12:04:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25490) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzTD4-0002ty-4I for qemu-devel@nongnu.org; Tue, 24 Jun 2014 12:04:38 -0400 Message-ID: <53A9A189.5050904@redhat.com> Date: Tue, 24 Jun 2014 10:04:25 -0600 From: Eric Blake MIME-Version: 1.0 References: <1403599971-9232-1-git-send-email-pl@kamp.de> In-Reply-To: <1403599971-9232-1-git-send-email-pl@kamp.de> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="hh27cSSlteiowvgpKp7o41ALTxERwqKcA" Subject: Re: [Qemu-devel] [PATCHv2] block/nfs: add knob to set readahead List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven , qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, ronniesahlberg@gmail.com, stefanha@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --hh27cSSlteiowvgpKp7o41ALTxERwqKcA Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 06/24/2014 02:52 AM, Peter Lieven wrote: > upcoming libnfs will feature internal readahead support. > Add a knob to pass the optional readahead value as a URL > parameter. >=20 > This patch fixes also the incorrect usage of strncmp and > atoi. >=20 > Signed-off-by: Peter Lieven > --- > v1->v2: use strtol instead of atoi [Eric] >=20 > block/nfs.c | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) >=20 > diff --git a/block/nfs.c b/block/nfs.c > index ec43201..9783483 100644 > --- a/block/nfs.c > +++ b/block/nfs.c > @@ -309,12 +309,16 @@ static int64_t nfs_client_open(NFSClient *client,= const char *filename, > qp->p[i].name); > goto fail; > } > - if (!strncmp(qp->p[i].name, "uid", 3)) { > - nfs_set_uid(client->context, atoi(qp->p[i].value)); > - } else if (!strncmp(qp->p[i].name, "gid", 3)) { > - nfs_set_gid(client->context, atoi(qp->p[i].value)); > - } else if (!strncmp(qp->p[i].name, "tcp-syncnt", 10)) { > - nfs_set_tcp_syncnt(client->context, atoi(qp->p[i].value));= > + if (!strcmp(qp->p[i].name, "uid")) { > + nfs_set_uid(client->context, strtol(qp->p[i].value, NULL, = 0)); If you're going to use strtol, use it correctly. You have to pre-set errno, then check that something got parsed, that errno was not changed, and that no unexpected suffix remains. Better is using a wrapper that already makes the parsing sane; such as parse_uint() from util/cutils.c. That is, swapping atoi() with a raw strtol() with no additional error checking is not fixing any of the bugs inherent in the fact that atoi() cannot detect overflow in user input. At this point, I'd rather see this split into two patches - one that fixes the atoi() usage, and another that adds readahead support - rather than trying to cram two things in one commit. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --hh27cSSlteiowvgpKp7o41ALTxERwqKcA 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 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTqaGJAAoJEKeha0olJ0NqFMsH/Azg9lpf7emBBuxUsNXtzwZD lZohmcTU4C8ALSraeUN/jGyFB4OtVaAd2nHePib9Q346HCQqKRjZAox9IneUhMHI bkglnXCtaCAJ/+jDL1GqaMUs526B5bOLUhYH30mMHEdhf/n89/XSkxK+xS/96+b7 miqgZUtJORS/aX2xeRtOsaxby1kIhjSppFap+SSluduVcKfxbZjxOKV0Xd85fFqp NAXwHJ7MujltocDh0D+C9SlTTfm6BDGot96av5nXFhQZGQRGjPX2ktLUinGM1c+P +34Tzyr/h0yK2NRrvtaRX9ySl27glRQTiE0dNNZZh8atkZ2Dla/rxMj9Bt/G77M= =DmhI -----END PGP SIGNATURE----- --hh27cSSlteiowvgpKp7o41ALTxERwqKcA--