From owner-svn-src-all@FreeBSD.ORG Sun Oct 16 18:20:34 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 76F84106564A; Sun, 16 Oct 2011 18:20:34 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: from mx0.hoeg.nl (mx0.hoeg.nl [IPv6:2a01:4f8:101:5343::aa]) by mx1.freebsd.org (Postfix) with ESMTP id 12D358FC08; Sun, 16 Oct 2011 18:20:34 +0000 (UTC) Received: by mx0.hoeg.nl (Postfix, from userid 1000) id 1DE842A28CC5; Sun, 16 Oct 2011 20:20:33 +0200 (CEST) Date: Sun, 16 Oct 2011 20:20:33 +0200 From: Ed Schouten To: Colin Percival Message-ID: <20111016182033.GS91943@hoeg.nl> References: <201110140724.p9E7OmMB052118@svn.freebsd.org> <4E9B1287.4050507@freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Taf0VO/VdHaNBIEp" Content-Disposition: inline In-Reply-To: <4E9B1287.4050507@freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r226359 - head/usr.bin/look X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Oct 2011 18:20:34 -0000 --Taf0VO/VdHaNBIEp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Colin Percival , 20111016 19:21: > This might make look(1) build, but on a 64-bit machine it also makes > look(1) fail with "File too large" whenever it's larger than > (int64_t)(UINT64_MAX) =3D -1 bytes long. d'oh! Stupid signedness. I casted to off_t explicitly, since we need to do 64-bit comparison, but off_t is signed, while size_t is not. Hmmm... Casting to size_t is not the way to go, but off_t also should be avoided. We can assume st_size is non-negative, so we should do something like this, right? %%% Index: look.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- look.c (revision 226430) +++ look.c (working copy) @@ -134,7 +134,7 @@ do { if ((fd =3D open(file, O_RDONLY, 0)) < 0 || fstat(fd, &sb)) err(2, "%s", file); - if (sb.st_size > (off_t)SIZE_T_MAX) + if ((uintmax_t)sb.st_size > (uintmax_t)SIZE_T_MAX) errx(2, "%s: %s", file, strerror(EFBIG)); if (sb.st_size =3D=3D 0) { close(fd); %%% --=20 Ed Schouten WWW: http://80386.nl/ --Taf0VO/VdHaNBIEp Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iQIcBAEBAgAGBQJOmyBwAAoJEG5e2P40kaK71ekQAITQU+dcxuPCm/xTaEU6CNOP /6C/zxPIpfOakYRb/qqAFMkyIukYVifgxc7FIpQ7+Nq0sgnc8wPB8btW7Daw4669 VOPjeuVfDOQpg+QBncuETRANlDABJd0TyBtNsh0ZWJLwDFfDtZTSt++0yWzmkoJ9 Cqu318bd61oUEyM7Xr8QX8/autANAaiYjbPmOIi4yFUxEA74Wn/ExncqTjdytTvQ vXnpSHJOqUPbD3WEKLOiJEp1AkxTqLgIMovLpITEmlM4x3qLDKebAg3ysTudmrI8 QbXBp2xME5YVRJa/KrBV5gp0I/juvAeoh0+ngr7xH6Gq/+qexxpBrDq+n+WSWZgC rjZhcRzoBk+qedkqq8nVJjkIooKuSAkD/Hrzjon0IKz+odG92miJLRdVBV+5jeZz 2BoRUcUGGAn4OGNigzEhvbmH90dYYbVHPkSyP4xWcio20PJvMMoPTewt8Z8ZQ2IX TbmSz7Z1zJ6TART5Str1WTX7GdwGgGsTDVAqHg+cPrBKEjbUVA2w2VR8gbX8uhfq orMqueW1Ycav7EjuVIJBypAjqiychOYt7FRenE8MInwthFAeyZxzhHtaSETTclD5 XWEjIIwW5xP7f2aZNX2pO/ziIULuIeNkGvr52BXRmfNvC0JMoV4q+dFiF8gOGXYQ Edp9CE9cs1eRDcXeheT8 =5U1D -----END PGP SIGNATURE----- --Taf0VO/VdHaNBIEp--