summary refs log tree commit diff
path: root/libio/iogets.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2019-02-03 09:37:30 +0100
committerFlorian Weimer <fweimer@redhat.com>2019-02-03 09:38:24 +0100
commitee9941f94ea838774c34f60b3397fba07a803d92 (patch)
tree082d81424de2bb74bd63f0087869c956ea437ad7 /libio/iogets.c
parentc70824b9a4645c0ecd049da8cfdb2c28ae7ada23 (diff)
downloadglibc-ee9941f94ea838774c34f60b3397fba07a803d92.tar.gz
glibc-ee9941f94ea838774c34f60b3397fba07a803d92.tar.xz
glibc-ee9941f94ea838774c34f60b3397fba07a803d92.zip
libio: Use stdin consistently for input functions [BZ #24153]
The internal _IO_stdin_ variable is not updated when the application
assigns to stdin, which is a GNU extension.
Diffstat (limited to 'libio/iogets.c')
-rw-r--r--libio/iogets.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/libio/iogets.c b/libio/iogets.c
index 2525056781..6691e4c0fc 100644
--- a/libio/iogets.c
+++ b/libio/iogets.c
@@ -34,8 +34,8 @@ _IO_gets (char *buf)
   int ch;
   char *retval;
 
-  _IO_acquire_lock (_IO_stdin);
-  ch = _IO_getc_unlocked (_IO_stdin);
+  _IO_acquire_lock (stdin);
+  ch = _IO_getc_unlocked (stdin);
   if (ch == EOF)
     {
       retval = NULL;
@@ -48,22 +48,22 @@ _IO_gets (char *buf)
       /* This is very tricky since a file descriptor may be in the
 	 non-blocking mode. The error flag doesn't mean much in this
 	 case. We return an error only when there is a new error. */
-      int old_error = _IO_stdin->_flags & _IO_ERR_SEEN;
-      _IO_stdin->_flags &= ~_IO_ERR_SEEN;
+      int old_error = stdin->_flags & _IO_ERR_SEEN;
+      stdin->_flags &= ~_IO_ERR_SEEN;
       buf[0] = (char) ch;
-      count = _IO_getline (_IO_stdin, buf + 1, INT_MAX, '\n', 0) + 1;
-      if (_IO_stdin->_flags & _IO_ERR_SEEN)
+      count = _IO_getline (stdin, buf + 1, INT_MAX, '\n', 0) + 1;
+      if (stdin->_flags & _IO_ERR_SEEN)
 	{
 	  retval = NULL;
 	  goto unlock_return;
 	}
       else
-	_IO_stdin->_flags |= old_error;
+	stdin->_flags |= old_error;
     }
   buf[count] = 0;
   retval = buf;
 unlock_return:
-  _IO_release_lock (_IO_stdin);
+  _IO_release_lock (stdin);
   return retval;
 }