Good spot - fixed, thanks.
On Fri, May 29, 2015 at 12:27:19PM +0200, S??bastien Marie wrote: > Hi, > > While working on file(1) for permit standard input type determination, I > investigate why when /dev/stdin is used, the output was 'data'. > > It seems that the fill_buffer function don't adjust inf->size to readed > buffer. So the test_file function may operate on larger buffer than > expected, considering garbage as potential data. > > before: > ------- > $ echo foobar | file -s /dev/stdin > /dev/stdin: data > > after: > ------ > $ echo foobar | file -s /dev/stdin > /dev/stdin: ASCII text > > Thanks. > -- > S??bastien Marie > > > Index: file.c > =================================================================== > RCS file: /cvs/src/usr.bin/file/file.c,v > retrieving revision 1.39 > diff -u -p -r1.39 file.c > --- file.c 28 May 2015 19:26:37 -0000 1.39 > +++ file.c 29 May 2015 10:23:17 -0000 > @@ -398,6 +409,7 @@ fill_buffer(struct input_file *inf) > left -= got; > } > > + inf->size -= left; > return buffer; > } >
