bin/107824: /usr/bin/head does not work with files over 2GB.
Brian Cornell
briancornell at earthlink.net
Thu Jan 11 06:20:14 PST 2007
>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 at 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:
More information about the freebsd-bugs
mailing list