Date: Thu, 11 Jan 2007 16:50:21 GMT From: Brooks Davis <brooks@one-eyed-alien.net> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/107824: /usr/bin/head does not work with files over 2GB. Message-ID: <200701111650.l0BGoL0o006203@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/107824; it has been noted by GNATS. From: Brooks Davis <brooks@one-eyed-alien.net> To: Brian Cornell <briancornell@earthlink.net> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200701111650.l0BGoL0o006203>