Date: Thu, 11 Jan 2007 14:19:04 GMT From: Brian Cornell<briancornell@earthlink.net> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/107824: /usr/bin/head does not work with files over 2GB. Message-ID: <200701111419.l0BEJ4e3041335@www.freebsd.org> Resent-Message-ID: <200701111420.l0BEKEKP093921@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 107824 >Category: bin >Synopsis: /usr/bin/head does not work with files over 2GB. >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Jan 11 14:20:13 GMT 2007 >Closed-Date: >Last-Modified: >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 <file> is a file that is larger than 2.5GB use the following syntax: head -c 2200000000 <file> 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: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200701111419.l0BEJ4e3041335>