Date: Sun, 29 Aug 2010 16:27:07 +0000 From: Alexander Best <arundel@freebsd.org> To: freebsd-hackers@freebsd.org Subject: hexdump(1)/od(1) skip function off-by-one when offset == file length Message-ID: <20100829162707.GA98059@freebsd.org>
next in thread | raw e-mail | index | archive | help
--KsGdsel6WgEHnImy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline just discovered this issue while going through some linux mailinglists: otaku% dd if=/dev/urandom of=testfile bs=1 count=42 42+0 records in 42+0 records out 42 bytes transferred in 0.000393 secs (106894 bytes/sec) otaku% hexdump -s 42 testfile 000002a 134d b7b9 e085 da16 63b0 554a 1603 ead0 000003a 4bd1 fbfd c329 b606 e592 1377 6e10 4b9d 000004a c018 0fc9 ebf4 9ae2 9f1a 0000054 otaku% hexdump -s 43 testfile 000002a otaku% hexdump -s 41 testfile 0000029 009f 000002a the attached patch fixes this issue for HEAD. i also checked out any license issues which could pop up. this fix comes from the util-linux-ng repository [1] which seems entirely GPLv2'ed. :) cheers. alex [1] http://git.kernel.org/?p=utils/util-linux-ng/util-linux-ng.git;a=tree;hb=HEAD ps: no fix for od(1) necessary since it's simply a hardlink to hexdump(1). ;) -- a13x --KsGdsel6WgEHnImy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="display.c.patch" diff --git a/usr.bin/hexdump/display.c b/usr.bin/hexdump/display.c index db04c49..3e3d903 100644 --- a/usr.bin/hexdump/display.c +++ b/usr.bin/hexdump/display.c @@ -378,7 +378,7 @@ doskip(const char *fname, int statok) if (statok) { if (fstat(fileno(stdin), &sb)) err(1, "%s", fname); - if (S_ISREG(sb.st_mode) && skip >= sb.st_size) { + if (S_ISREG(sb.st_mode) && skip > sb.st_size) { address += sb.st_size; skip -= sb.st_size; return; --KsGdsel6WgEHnImy--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100829162707.GA98059>