Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Fri, 29 May 2015 00:32:38 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: stdio fixes & internals documentation

On Thu, May 28, 2015 at 09:39:37PM -0400, Rich Felker wrote:
> Once these fixes are taken care of I'd like to look at the EOF logic
> in f->read() and moving it out to the callers (only __uflow and fread)
> where we won't have to worry about bugs (which I think exist) in the
> FILE-type-specific read functions.

Actually there don't seem to be such bugs, so I'm not in a big hurry
to make changes here. I did notice one issue though with __toread and
__towrite: they set the error status for the FILE when an illegal
operation (per the fopen mode) is attempted, but they don't set errno.
glibc sets errno to EBADF in this case, which I'm not sure is a
permitted behavior. POSIX says:

[EBADF]
    [CX] [Option Start] The file descriptor underlying stream is not a
    valid file descriptor open for reading. [Option End]

So if the underlying fd allows reading but the fopen mode doesn't, I
think this would be reusing a specified errno value with a meaning
distinct from the specified meaning, and thus non-conforming. I don't
know what would be an appropriate errno value, though.

On the other hand, the general text for EBADF reads:

[EBADF]
    Bad file descriptor. A file descriptor argument is out of range,
    refers to no open file, or a read (write) request is made to a
    file that is only open for writing (reading).

which makes it sound more permissible here.

Rich

Powered by blists - more mailing lists

Your e-mail address:

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.