summaryrefslogtreecommitdiffstats
path: root/newlib/libc/stdio/puts.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-07-01 15:35:00 +0200
committerCorinna Vinschen <corinna@vinschen.de>2015-07-02 09:38:06 +0200
commit757c0871f74c3a2d682398490bcae8873d1fafd4 (patch)
treeddb8fe5fd222b13cc247c14e08b2f4aab8ec97aa /newlib/libc/stdio/puts.c
parentfc22f775032cff7100166c32ab562b48578ee0dc (diff)
downloadcygnal-757c0871f74c3a2d682398490bcae8873d1fafd4.tar.gz
cygnal-757c0871f74c3a2d682398490bcae8873d1fafd4.tar.bz2
cygnal-757c0871f74c3a2d682398490bcae8873d1fafd4.zip
Prevent use of uninitialized file lock
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 (_puts_r): Add missing CHECK_INIT(). libc/stdio/gets.c (_gets_r): Add missing _REENT_SMALL_CHECK_INIT() and CHECK_INIT(). Use _stdin_r() to get the file pointer instead of stdin. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'newlib/libc/stdio/puts.c')
-rw-r--r--newlib/libc/stdio/puts.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/newlib/libc/stdio/puts.c b/newlib/libc/stdio/puts.c
index 4c60aaa4c..74673715f 100644
--- a/newlib/libc/stdio/puts.c
+++ b/newlib/libc/stdio/puts.c
@@ -95,6 +95,7 @@ _DEFUN(_puts_r, (ptr, s),
_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');
@@ -107,6 +108,7 @@ _DEFUN(_puts_r, (ptr, s),
_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. */