[PATCH] Prevent use of uninitialized file lock
Corinna Vinschen
vinschen@redhat.com
Wed Jul 1 13:35:00 GMT 2015
On Jul 1 14:58, Sebastian Huber wrote:
>
>
> On 01/07/15 14:52, Sebastian Huber wrote:
> >>
> >>Btw., don't we have the same problem in libc/stdio/gets.c as well?
> >
> >Probably yes. It seems a _REENT_SMALL_CHECK_INIT (ptr) is missing as well?
> >I try to add this to the second version.
>
> This _gets_r() looks quite dubious:
>
> char *
> _DEFUN(_gets_r, (ptr, buf),
> struct _reent *ptr _AND
> char *buf)
> {
> register int c;
> register char *s = buf;
>
> _newlib_flockfile_start (stdin);
> while ((c = __sgetc_r (ptr, stdin)) != '\n')
> if (c == EOF)
> if (s == buf)
> {
> _newlib_flockfile_exit (stdin);
> return NULL;
> }
> else
> break;
> else
> *s++ = c;
> *s = 0;
> _newlib_flockfile_end (stdin);
> return buf;
> }
>
> We have:
>
> #define stdin (_REENT->_stdin)
>
> so we don't use the ptr->_stdin? Is this intentional?
I don't know. It looks like an oversight, but I'm not sure.
Jeff, any idea?
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20150701/d10b1743/attachment.sig>
More information about the Newlib
mailing list