This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: [PATCH] Prevent use of uninitialized file lock
- From: Sebastian Huber <sebastian dot huber at embedded-brains dot de>
- To: newlib at sourceware dot org
- Date: Wed, 01 Jul 2015 14:58:12 +0200
- Subject: Re: [PATCH] Prevent use of uninitialized file lock
- Authentication-results: sourceware.org; auth=none
- References: <1435735590-4936-1-git-send-email-sebastian dot huber at embedded-brains dot de> <20150701123349 dot GL2918 at calimero dot vinschen dot de> <5593E29B dot 2010300 at embedded-brains dot de>
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?
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.huber@embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschÃftliche Mitteilung im Sinne des EHUG.