From owner-freebsd-hackers@FreeBSD.ORG Mon Nov 9 07:19:37 2009 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4EE3E1065693 for ; Mon, 9 Nov 2009 07:19:37 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from poseidon.ceid.upatras.gr (poseidon.ceid.upatras.gr [150.140.141.169]) by mx1.freebsd.org (Postfix) with ESMTP id B52F18FC1B for ; Mon, 9 Nov 2009 07:19:35 +0000 (UTC) Received: from mail.ceid.upatras.gr (unknown [10.1.0.143]) by poseidon.ceid.upatras.gr (Postfix) with ESMTP id E799AEB47CD; Mon, 9 Nov 2009 09:19:34 +0200 (EET) Received: from localhost (europa.ceid.upatras.gr [127.0.0.1]) by mail.ceid.upatras.gr (Postfix) with ESMTP id D1CB2452F9; Mon, 9 Nov 2009 09:19:34 +0200 (EET) X-Virus-Scanned: amavisd-new at ceid.upatras.gr Received: from mail.ceid.upatras.gr ([127.0.0.1]) by localhost (europa.ceid.upatras.gr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6-LWZYCuhYcl; Mon, 9 Nov 2009 09:19:34 +0200 (EET) Received: from kobe.laptop (adsl317-61.kln.forthnet.gr [188.4.41.61]) by mail.ceid.upatras.gr (Postfix) with ESMTP id 725E1451B2; Mon, 9 Nov 2009 09:19:34 +0200 (EET) Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.3/8.14.3) with ESMTP id nA97JXEE016257 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 9 Nov 2009 09:19:33 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.3/8.14.3/Submit) id nA97JX3O016256; Mon, 9 Nov 2009 09:19:33 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) From: Giorgos Keramidas To: Alexander Best References: Date: Mon, 09 Nov 2009 09:19:33 +0200 In-Reply-To: (Alexander Best's message of "Mon, 09 Nov 2009 02:22:36 +0100 (CET)") Message-ID: <87y6mg17y2.fsf@kobe.laptop> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Cc: freebsd-hackers@FreeBSD.org, Gabor Kovesdan Subject: Re: [patch] burncd: honour for envar SPEED X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Nov 2009 07:19:37 -0000 --=-=-= On Mon, 09 Nov 2009 02:22:36 +0100 (CET), Alexander Best wrote: > --- burncd.c.typo 2009-11-09 02:19:47.000000000 +0100 > +++ burncd.c 2009-11-09 02:20:27.000000000 +0100 > @@ -85,8 +85,8 @@ > if ((dev = getenv("CDROM")) == NULL) > dev = "/dev/acd0"; > > - if ((env_speed = getenv("WRITE_SPEED")) != NULL) > - if (strcasecmp("max", getenv) == 0) > + if ((env_speed = getenv("WRITE_SPEED")) != NULL) { > + if (strcasecmp("max", env_speed) == 0) > speed = CDR_MAX_SPEED; > else > speed = atoi(env_speed) * 177; atoi() doesn't really have error checking and it does not necessarily affect `errno'. I'd probably prefer something that uses strtoul() and a few more value/range checks, i.e.: : #include : #include : : { : char *endp; : long xspeed; : : speed = 4 * 177; : if ((env_speed = getenv("SPEED")) != NULL) { : if (strcasecmp("max", env_speed) == 0) { : speed = CDR_MAX_SPEED; : } else { : end = NULL; : errno = 0; : xspeed = strtol(env_speed, &endp, 0); : if (errno != 0 || (endp != NULL && endp != str && : *endp != '\0' && (isdigit(*endp) != 0 || : isspace(*endp) == 0))) : err(1, "invalid write speed: %s", env_speed); : if (xspeed < 0 || xspeed > INT_MAX) : err(1, "write speed out of range: %ld", xspeed); : speed = (int)xspeed * 177; : } : } : } --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (FreeBSD) iEYEARECAAYFAkr3woUACgkQ1g+UGjGGA7agFQCgqABc/G2c+47gxRnqiK81gcyJ PDMAniHujYEVHvgmUk+0ooepIwI778kT =OfHv -----END PGP SIGNATURE----- --=-=-=--