This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug stdio/21398] freopen does not check dup3 return value, and does not return error if dup3 fails (seen when open returns fd 0, and freopen on stdin)


https://sourceware.org/bugzilla/show_bug.cgi?id=21398

--- Comment #6 from Dave Olson <olson at cumulusnetworks dot com> ---
It's not trying to use a stream where the underlying fd is closed, it's trying
to create stdin.

Think of processes that are exec'ed without fd 0 open (which is the real test
case, because it's marked close on exec).

What it's trying to do is to establish a stdin for use with functions that
expect to use stdin.

Even if you don't accept that as a valid use case (and I can accept the
argument, even though I don't agree with it), freopen() should be returning an
error, which means it needs to check for dup3 returning errors.

Right now, freopen in this situation returns what appears to be a valid FILE *,
but the requested action on stdin will fail.

So the minimum is to check for dup3() errors, and then return an error from
freopen().

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]