memchr() strangeness
Alfred Perlstein
alfred at freebsd.org
Fri Sep 4 17:25:11 UTC 2009
Moved to -hackers.
Gabor, can you please make a smaller program to exhibit this behavior?
(not just the error line)
I will be glad to help out.
-Alfred
* Gabor Kovesdan <gabor at FreeBSD.org> [090904 10:04] wrote:
> Hello,
>
> having returned from vacation, I'm trying to track down the (hopefully)
> last critical bug in BSDL grep I worked on the last summer. The binary
> file detection is implemented as follows:
> f->binary = memchr(binbuf, (filebehave != FILE_GZIP) ? '\0' : '\200', i
> - 1) != NULL;
>
> There's some strange with this. In my normal environment it works fine:
> server# echo foobar | ./grep -v '^ *+'
> foobar
>
> But in a chroot environment the binary detection is broken:
> # echo foobar | grep -v '^ *+'
> foobar
> Binary file (standard input) matches
>
> I don't know where things go bad. I've tried to print out the content of
> the buffer and the buffer length and they are the same but somehow in
> the chrooted environment this sets f->binary to true.
> Any suggestions?
>
> Thanks in advance,
>
> --
> Gabor Kovesdan
> FreeBSD Volunteer
>
> EMAIL: gabor at FreeBSD.org .:|:. gabor at kovesdan.org
> WEB: http://people.FreeBSD.org/~gabor .:|:. http://kovesdan.org
>
> --
> This mail is for the internal use of the FreeBSD project committers,
> and as such is private. This mail may not be published or forwarded
> outside the FreeBSD committers' group or disclosed to other unauthorised
> parties without the explicit permission of the author(s).
--
- Alfred Perlstein
.- AMA, VMOA #5191, 03 vmax, 92 gs500, 85 ch250
.- FreeBSD committer
More information about the freebsd-hackers
mailing list