This is the mail archive of the newlib@sourceware.org mailing list for the newlib 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]

[PATCH] Prevent use of uninitialized file lock


I am not sure if CHECK_INIT() is doing the right thing in case
_REENT_SMALL is defined.  The CHECK_INIT() is necessary before the
_newlib_flockfile_start() since this would use otherwise acquire an
uninitialized lock which gets initialized after this leading to a
corrupt release.

newlib/ChangeLog
2015-07-01  Sebastian Huber  <sebastian.huber@embedded-brains.de>

	libc/stdio/fputs.c: Add missing CHECK_INIT().
---
 newlib/libc/stdio/puts.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/newlib/libc/stdio/puts.c b/newlib/libc/stdio/puts.c
index 4c60aaa..95ce607 100644
--- a/newlib/libc/stdio/puts.c
+++ b/newlib/libc/stdio/puts.c
@@ -93,8 +93,8 @@ _DEFUN(_puts_r, (ptr, s),
   uio.uio_iov = &iov[0];
   uio.uio_iovcnt = 2;
 
-  _REENT_SMALL_CHECK_INIT (ptr);
   fp = _stdout_r (ptr);
+  CHECK_INIT (ptr, fp);
   _newlib_flockfile_start (fp);
   ORIENT (fp, -1);
   result = (__sfvwrite_r (ptr, fp, &uio) ? EOF : '\n');
@@ -104,9 +104,9 @@ _DEFUN(_puts_r, (ptr, s),
   int result = EOF;
   const char *p = s;
   FILE *fp;
-  _REENT_SMALL_CHECK_INIT (ptr);
 
   fp = _stdout_r (ptr);
+  CHECK_INIT (ptr, fp);
   _newlib_flockfile_start (fp);
   ORIENT (fp, -1);
   /* Make sure we can write.  */
-- 
1.8.4.5


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