[PATCH] Prevent use of uninitialized file lock
Sebastian Huber
sebastian.huber@embedded-brains.de
Wed Jul 1 12:33:00 GMT 2015
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
More information about the Newlib
mailing list