Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Jan 2003 11:56:08 +1100 (EST)
From:      Tim Robbins <tim@robbins.dropbear.id.au>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   standards/46791: freopen() does not handle filename == NULL correctly
Message-ID:  <200301060056.h060u8BY018069@dilbert.robbins.dropbear.id.au>

next in thread | raw e-mail | index | archive | help

>Number:         46791
>Category:       standards
>Synopsis:       freopen() does not handle filename == NULL correctly
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-standards
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 05 17:00:07 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Tim Robbins
>Release:        FreeBSD 4.7-RELEASE-p2 i386
>Organization:
FreeBSD
>Environment:
N/A
>Description:

ISO/IEC 9899:1999 ("C99") section 7.19.5.4 contains the following text:

3 If filename is a null pointer, the freopen function attempts to change
the mode of the stream to that specified by mode, as if the name of the file
currently associated with the stream had been used. It is
implementation-defined which changes of mode are permitted (if any),
and under what circumstances.
(end quote)

It could be sufficient to just check that the mode is the same as the one
passed to fopen() and to do nothing if it is or to close the file and return
NULL otherwise.

>How-To-Repeat:
freopen(NULL, "r", stdin); passes NULL to open(2), causing freopen() to
return NULL with errno = EFAULT.
>Fix:
Not provided.
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-standards" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200301060056.h060u8BY018069>