From owner-freebsd-bugs@FreeBSD.ORG Thu Jan 11 16:50:21 2007 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DC99416A403 for ; Thu, 11 Jan 2007 16:50:21 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.freebsd.org (Postfix) with ESMTP id BA9C313C428 for ; Thu, 11 Jan 2007 16:50:21 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id l0BGoLmw006205 for ; Thu, 11 Jan 2007 16:50:21 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id l0BGoL0o006203; Thu, 11 Jan 2007 16:50:21 GMT (envelope-from gnats) Date: Thu, 11 Jan 2007 16:50:21 GMT Message-Id: <200701111650.l0BGoL0o006203@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Brooks Davis Cc: Subject: Re: bin/107824: /usr/bin/head does not work with files over 2GB. X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Brooks Davis List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jan 2007 16:50:21 -0000 The following reply was made to PR bin/107824; it has been noted by GNATS. From: Brooks Davis To: Brian Cornell Cc: freebsd-gnats-submit@freebsd.org Subject: Re: bin/107824: /usr/bin/head does not work with files over 2GB. Date: Thu, 11 Jan 2007 10:03:37 -0600 On Thu, Jan 11, 2007 at 02:19:04PM +0000, Brian Cornell wrote: > > Change byte counters in head.c from long to double types. This has been tested & works. > Output of diff from release to modified source code: > diff head.c head.61freebsd > 64c64 > < static void head_bytes(FILE *, double); > --- > > static void head_bytes(FILE *, size_t); > 73,74c73 > < int first, linecnt = -1, eval = 0; > < double bytecnt = -1; > --- > > int first, linecnt = -1, bytecnt = -1, eval = 0; > 81c80 > < bytecnt = strtod(optarg, &ep); > --- > > bytecnt = strtol(optarg, &ep, 10); > 142c141 > < head_bytes(FILE *fp, double cnt) > --- > > head_bytes(FILE *fp, size_t cnt) > 145c144 > < double readlen; > --- > > size_t readlen; This is bogus. Using a floating point type to hold an interger quantity is wrong. The correct type here is off_t. I'd suggest using strtoll or strtonum for the conversion. -- Brooks