From owner-svn-src-head@FreeBSD.ORG Sun Oct 16 18:39:11 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DE81E106567B for ; Sun, 16 Oct 2011 18:39:11 +0000 (UTC) (envelope-from bounces+73574-9504-svn-src-head=freebsd.org@sendgrid.me) Received: from o2.shared.sendgrid.net (o2.shared.sendgrid.net [74.63.235.152]) by mx1.freebsd.org (Postfix) with SMTP id 9464B8FC16 for ; Sun, 16 Oct 2011 18:39:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.info; h= message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type:content-transfer-encoding; s=smtpapi; bh=Aok4ZANUptSZF/k6pBjI3PMACp8=; b=F0b4te2vR1a+JachKlzRlFpLIzHj l/34QLN2+ZYLQtUQDfEUpU7Ec22dDYVdlePIzHyWDpHNje0MgkPHVnwq6Wta850p NGI4Vw1TAQINtWjlRTqecUYjNonuIPkTLNz5Wy0dYgr5uXgaeJOZg2gBC1q0Enz+ RtXboMYExf2k+sQ= Received: by 10.12.16.8 with SMTP id mf37.3695.4E9B24CEA Sun, 16 Oct 2011 13:39:10 -0500 (CDT) Received: from mail.tarsnap.com (unknown [10.9.180.5]) by mi11 (SG) with ESMTP id 4e9b24ce.53cb.570fe0c for ; Sun, 16 Oct 2011 13:39:10 -0500 (CST) Received: (qmail 56255 invoked from network); 16 Oct 2011 18:36:51 -0000 Received: from unknown (HELO clamshell.daemonology.net) (127.0.0.1) by mail.tarsnap.com with ESMTP; 16 Oct 2011 18:36:51 -0000 Received: (qmail 78187 invoked from network); 16 Oct 2011 18:38:40 -0000 Received: from unknown (HELO clamshell.daemonology.net) (127.0.0.1) by clamshell.daemonology.net with SMTP; 16 Oct 2011 18:38:40 -0000 Message-ID: <4E9B24B0.60106@freebsd.org> Date: Sun, 16 Oct 2011 11:38:40 -0700 From: Colin Percival User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:6.0.2) Gecko/20110914 Thunderbird/6.0.2 MIME-Version: 1.0 To: Ed Schouten References: <201110140724.p9E7OmMB052118@svn.freebsd.org> <4E9B1287.4050507@freebsd.org> <20111016182033.GS91943@hoeg.nl> In-Reply-To: <20111016182033.GS91943@hoeg.nl> X-Enigmail-Version: undefined Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Sendgrid-EID: EvYvoie/qnEezyq2t4eRKjDm9X7ZKbCMt75WvXA+XNG0vxZEW+W746qi3T5RfEzWhpaEsLcVyBlkBUedDM9PwxrXcoFMZY8ilCLyTorAMk/iF+uCwxGv8b4GDDJwMu/3c/Stk6OREjbbsJc5o/gkMIzXgS7eEB99NMYaGyHlDJU= 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-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Oct 2011 18:39:12 -0000 On 10/16/11 11:20, Ed Schouten wrote: > 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? > > - if (sb.st_size > (off_t)SIZE_T_MAX) > + if ((uintmax_t)sb.st_size > (uintmax_t)SIZE_T_MAX) That should work. I've also solved this problem in the past with if ((sizeof(off_t) > sizeof(size_t)) && (sb.st_size > (off_t) -- Colin Percival Security Officer, FreeBSD | freebsd.org | The power to serve Founder / author, Tarsnap | tarsnap.com | Online backups for the truly paranoid