From owner-svn-src-all@FreeBSD.ORG Sun Oct 16 19:15:25 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 98D31106566B; Sun, 16 Oct 2011 19:15:25 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 88CE08FC13; Sun, 16 Oct 2011 19:15:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p9GJFPlb075847; Sun, 16 Oct 2011 19:15:25 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p9GJFPpo075845; Sun, 16 Oct 2011 19:15:25 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201110161915.p9GJFPpo075845@svn.freebsd.org> From: Ed Schouten Date: Sun, 16 Oct 2011 19:15:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r226444 - 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 19:15:25 -0000 Author: ed Date: Sun Oct 16 19:15:25 2011 New Revision: 226444 URL: http://svn.freebsd.org/changeset/base/226444 Log: Don't cast SIZE_T_MAX to off_t. I focused so much on the 32-bits case where we have to cast SIZE_T_MAX up in size, that I forgot about the 64-bits case, where off_t and size_t are equal in size. Simply cast both numbers to uintmax_t, as we can assume st_size is never negative. Reported by: cperciva Modified: head/usr.bin/look/look.c Modified: head/usr.bin/look/look.c ============================================================================== --- head/usr.bin/look/look.c Sun Oct 16 17:59:28 2011 (r226443) +++ head/usr.bin/look/look.c Sun Oct 16 19:15:25 2011 (r226444) @@ -134,7 +134,7 @@ main(int argc, char *argv[]) do { if ((fd = 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 == 0) { close(fd);