bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: putc(-1) == EOF on IRIX in frcode


From: Eric Blake
Subject: Re: putc(-1) == EOF on IRIX in frcode
Date: Tue, 14 Jun 2016 11:37:05 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

[adding bug-gnulib]

On 06/12/2016 03:47 PM, Rainer M. Canavan wrote:
> I've noticed that updatedb has consistently failed since upgrading
> to findutils 4.6.0. I'm using IRIX 6.5.30 and the mipspro compilers.

Thanks for the report.

> 
> It turns out that frcode assumes that a write error has occurred, 
> although in reality everything went well, because 
> putc(-1, stdout) returns -1 on success _and_ failure, since 
> EOF == -1, and therefore in frcode.c, line 335:
> 
> if (EOF == putc (diffcount, stdout))
> 
> exits with "write error". I'm not sure why this isn't always triggered 
> if (diffcount == -1), but I haven't checked if the same codepath is 
> always taken. 

That's a bug in IRIX putc(); POSIX is clear that putc() is supposed to
cast its argument to unsigned char before writing to the stream, and
then return the character just written.

Gnulib should be taught to work around the bug.

> 
> A possible fix would be to cast diffcount to unsigned char, this
> appears to work (and results in a valid locatedb) on both 
> linux and irix:
> 
> putc ((unsigned char)diffcount, stdout))

This workaround should be embedded in gnulib, so that findutils can
continue to use putc() without the cast.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]