From nobody@FreeBSD.org Thu Jan 11 14:19:04 2007 Return-Path: Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DC9D216A407 for ; Thu, 11 Jan 2007 14:19:04 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [69.147.83.33]) by mx1.freebsd.org (Postfix) with ESMTP id CDA7313C461 for ; Thu, 11 Jan 2007 14:19:04 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l0BEJ4OO041336 for ; Thu, 11 Jan 2007 14:19:04 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id l0BEJ4e3041335; Thu, 11 Jan 2007 14:19:04 GMT (envelope-from nobody) Message-Id: <200701111419.l0BEJ4e3041335@www.freebsd.org> Date: Thu, 11 Jan 2007 14:19:04 GMT From: Brian Cornell To: freebsd-gnats-submit@FreeBSD.org Subject: /usr/bin/head does not work with files over 2GB. X-Send-Pr-Version: www-3.0 >Number: 107824 >Category: bin >Synopsis: /usr/bin/head does not work with files over 2GB. >Confidential: no >Severity: non-critical >Priority: low >Responsible: brooks >State: closed >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Jan 11 14:20:13 GMT 2007 >Closed-Date: Mon Jan 15 17:12:24 GMT 2007 >Last-Modified: Mon Jan 15 17:20:18 GMT 2007 >Originator: Brian Cornell >Release: 6.1 Release 0 >Organization: N/A >Environment: FreeBSD basement.divergentllc.com 6.1-RELEASE FreeBSD 6.1-RELEASE #0: Sun May 7 04:42:56 UTC 2006 root@opus.cse.buffalo.edu:/usr/obj/usr/src/sys/SMP i386 >Description: When the '-c' option in head is passed an integer greater than 2147483647 it will not stop output at requested value but will instead continue output until EOF. >How-To-Repeat: Where is a file that is larger than 2.5GB use the following syntax: head -c 2200000000 Head will output the entire file instead of the first 2.2GB. >Fix: 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; END OUTPUT. >Release-Note: >Audit-Trail: 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 From: dfilter@FreeBSD.ORG (dfilter service) To: bug-followup@FreeBSD.org Cc: Subject: Re: bin/107824: commit references a PR Date: Thu, 11 Jan 2007 17:04:09 +0000 (UTC) brooks 2007-01-11 17:03:51 UTC FreeBSD src repository Modified files: usr.bin/head Makefile head.c Log: Fix head -c ### where ### is greater than 2^31. Unlike the submitted patch this uses off_t. WARNSify and add $FreeBSD$ to Makefile. PR: bin/107824 Submitted by: Brian Cornell MFC after: 3 days Revision Changes Path 1.2 +2 -0 src/usr.bin/head/Makefile 1.19 +6 -4 src/usr.bin/head/head.c _______________________________________________ cvs-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/cvs-all To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org" State-Changed-From-To: open->patched State-Changed-By: brooks State-Changed-When: Thu Jan 11 17:47:50 UTC 2007 State-Changed-Why: Fixed in HEAD. Responsible-Changed-From-To: freebsd-bugs->brooks Responsible-Changed-By: brooks Responsible-Changed-When: Thu Jan 11 17:47:50 UTC 2007 Responsible-Changed-Why: Fixed in HEAD. http://www.freebsd.org/cgi/query-pr.cgi?pr=107824 State-Changed-From-To: patched->closed State-Changed-By: brooks State-Changed-When: Mon Jan 15 17:11:51 UTC 2007 State-Changed-Why: Merged to RELENG_6. Will be in 6.3-RELEASE. http://www.freebsd.org/cgi/query-pr.cgi?pr=107824 From: dfilter@FreeBSD.ORG (dfilter service) To: bug-followup@FreeBSD.org Cc: Subject: Re: bin/107824: commit references a PR Date: Mon, 15 Jan 2007 17:11:47 +0000 (UTC) brooks 2007-01-15 17:11:38 UTC FreeBSD src repository Modified files: (Branch: RELENG_6) usr.bin/head Makefile head.c Log: MFC: head.c revs 1.19-20, Makefile rev 1.2 Fix head -c ### where ### is greater than 2^31. Unlike the submitted patch this uses off_t. WARNSify and add $FreeBSD$ to Makefile. PR: bin/107824 Submitted by: Brian Cornell Revision Changes Path 1.1.1.1.46.1 +2 -0 src/usr.bin/head/Makefile 1.18.14.1 +7 -5 src/usr.bin/head/head.c _______________________________________________ cvs-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/cvs-all To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org" >Unformatted: