On Sun, Sep 15, 2013 at 05:23:09AM -0400, hhm wrote:
> Found 2 bugs in `od`, not very familiar with the code so just reporting them:
>
>
> 1. -t <integer-type>0 does not work correctly (loops infinitely while
> printing 0)
That's supposed to work at all?
$ od -t x0 </bin/true
od: invalid type string `x0';
this system doesn't provide a 0-byte integral type
Although it probably makes sense to disallow it rather than hoping
that some user won't break things...
> 2. -J does not seem to have an effect (although it looks like there is
> some code which does reference/use it)
I presume you mean '[-j #]' ?
That appears to not have an effect; it should skip '#' bytes.
And it's not documented in the help message...
Hmm...
if (TT.jump_bytes < TT.pos) {
off_t off = lskip(fd, TT.jump_bytes);
if (off > 0) TT.pos += off;
if (TT.jump_bytes < TT.pos) return;
}
Let's see what happens with -j 16, one small (8 byte) file:
if (TT.jump_bytes < TT.pos)
becomes
if (16 < 0)
Should be if (TT.jump_bytes > TT.pos).
If we got past that, off becomes the filesize, so TT.pos is 8.
if (TT.jump_bytes < TT.pos) return;
becomes
if (16 < 8) return;
That is wrong. We should be returning if (16 > 8).
Of course, TT.pos appears to need reinitializing to 0 before this...
But the obvious patch doesn't work.
(inserts fprintf)
And it appears that off is 0. So lskip is returning 0:
if (and != -1 && offset >= lseek(fd, offset, SEEK_END)
&& offset+and == lseek(fd, offset+and, SEEK_SET)) return 0;
And the other path returns 0:
while (offset) {
//read loop, which decrements offset by bytes read
}
return offset;
I'm not sure how to fix this mess. Should lskip return bytes left to fill
the request (0 if success), or bytes advanced?
HTH,
Isaac Dunham
_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net