diff options
author | brooks <brooks@FreeBSD.org> | 2007-01-11 17:03:51 +0000 |
---|---|---|
committer | brooks <brooks@FreeBSD.org> | 2007-01-11 17:03:51 +0000 |
commit | fa972955217712cc70fc90adcd8f63c15912f2ea (patch) | |
tree | 507d7058d23488cd6476d15ef508639a3109623d /usr.bin/head | |
parent | 3b33e7a4f8cd8647568dff5c14610900eb48da44 (diff) | |
download | FreeBSD-src-fa972955217712cc70fc90adcd8f63c15912f2ea.zip FreeBSD-src-fa972955217712cc70fc90adcd8f63c15912f2ea.tar.gz |
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 <briancornell at earthlink dot net>
MFC after: 3 days
Diffstat (limited to 'usr.bin/head')
-rw-r--r-- | usr.bin/head/Makefile | 2 | ||||
-rw-r--r-- | usr.bin/head/head.c | 10 |
2 files changed, 8 insertions, 4 deletions
diff --git a/usr.bin/head/Makefile b/usr.bin/head/Makefile index b0b911e..002b3f3 100644 --- a/usr.bin/head/Makefile +++ b/usr.bin/head/Makefile @@ -1,5 +1,7 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 +# $FreeBSD$ PROG= head +WARNS= 6 .include <bsd.prog.mk> diff --git a/usr.bin/head/head.c b/usr.bin/head/head.c index eb20446..36aa9bf 100644 --- a/usr.bin/head/head.c +++ b/usr.bin/head/head.c @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include <ctype.h> #include <err.h> +#include <inttypes.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -61,7 +62,7 @@ __FBSDID("$FreeBSD$"); */ static void head(FILE *, int); -static void head_bytes(FILE *, size_t); +static void head_bytes(FILE *, off_t); static void obsolete(char *[]); static void usage(void); @@ -70,14 +71,15 @@ main(int argc, char *argv[]) { int ch; FILE *fp; - int first, linecnt = -1, bytecnt = -1, eval = 0; + int first, linecnt = -1, eval = 0; + off_t bytecnt = -1; char *ep; obsolete(argv); while ((ch = getopt(argc, argv, "n:c:")) != -1) switch(ch) { case 'c': - bytecnt = strtol(optarg, &ep, 10); + bytecnt = strtoimax(optarg, &ep, 10); if (*ep || bytecnt <= 0) errx(1, "illegal byte count -- %s", optarg); break; @@ -138,7 +140,7 @@ head(FILE *fp, int cnt) } static void -head_bytes(FILE *fp, size_t cnt) +head_bytes(FILE *fp, off_t cnt) { char buf[4096]; size_t readlen; |