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

Fix getpass fflush_unlocked namespace (bug 18540)


The getpass function (XPG3 / XPG4 / UNIX98) calls fflush_unlocked (not
in any of those standards).  This patch fixes this by making
fflush_unlocked into a weak alias for __fflush_unlocked and calling
__fflush_unlocked from getpass.

Tested for x86_64 and x86 (testsuite, and that disassembly of
installed stripped shared libraries is unchanged by the patch).

2015-06-15  Joseph Myers  <joseph@codesourcery.com>

	[BZ #18540]
	* libio/iofflush.c [!_IO_MTSAFE_IO] (__fflush_unlocked): Define as
	strong alias of _IO_fflush.  Use libc_hidden_def.
	* libio/iofflush_u.c (fflush_unlocked): Rename to
	__fflush_unlocked and define as weak alias of __fflush_unlocked.
	Use libc_hidden_weak.
	* include/stdio.h (__fflush_unlocked): Declare.  Use
	libc_hidden_proto.
	* misc/getpass.c (getpass): Call __fflush_unlocked instead of
	fflush_unlocked.
	* conform/Makefile (test-xfail-UNIX98/unistd.h/linknamespace):
	Remove variable.

diff --git a/conform/Makefile b/conform/Makefile
index 4bbc1e6..32d2985 100644
--- a/conform/Makefile
+++ b/conform/Makefile
@@ -348,5 +348,4 @@ test-xfail-XPG3/unistd.h/linknamespace = yes
 test-xfail-XPG4/unistd.h/linknamespace = yes
 test-xfail-POSIX/mqueue.h/linknamespace = yes
 test-xfail-UNIX98/mqueue.h/linknamespace = yes
-test-xfail-UNIX98/unistd.h/linknamespace = yes
 test-xfail-UNIX98/wchar.h/linknamespace = yes
diff --git a/include/stdio.h b/include/stdio.h
index 9cd324b..5e50e63 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -155,6 +155,8 @@ extern __typeof (ftello) __ftello;
 libc_hidden_proto (__ftello)
 libc_hidden_proto (fflush)
 libc_hidden_proto (fflush_unlocked)
+extern __typeof (fflush_unlocked) __fflush_unlocked;
+libc_hidden_proto (__fflush_unlocked)
 extern __typeof (fread_unlocked) __fread_unlocked;
 libc_hidden_proto (__fread_unlocked)
 libc_hidden_proto (fwrite_unlocked)
diff --git a/libio/iofflush.c b/libio/iofflush.c
index 106f55f..236e145 100644
--- a/libio/iofflush.c
+++ b/libio/iofflush.c
@@ -50,6 +50,8 @@ weak_alias (_IO_fflush, fflush)
 libc_hidden_weak (fflush)
 
 #ifndef _IO_MTSAFE_IO
+strong_alias (_IO_fflush, __fflush_unlocked)
+libc_hidden_def (__fflush_unlocked)
 weak_alias (_IO_fflush, fflush_unlocked)
 libc_hidden_weak (fflush_unlocked)
 #endif
diff --git a/libio/iofflush_u.c b/libio/iofflush_u.c
index 6cc325a..e004479 100644
--- a/libio/iofflush_u.c
+++ b/libio/iofflush_u.c
@@ -28,7 +28,7 @@
 #include <stdio.h>
 
 int
-fflush_unlocked (fp)
+__fflush_unlocked (fp)
      _IO_FILE *fp;
 {
   if (fp == NULL)
@@ -39,4 +39,6 @@ fflush_unlocked (fp)
       return _IO_SYNC (fp) ? EOF : 0;
     }
 }
-libc_hidden_def (fflush_unlocked)
+libc_hidden_def (__fflush_unlocked)
+weak_alias (__fflush_unlocked, fflush_unlocked)
+libc_hidden_weak (fflush_unlocked)
diff --git a/misc/getpass.c b/misc/getpass.c
index 36796db..dcaff38 100644
--- a/misc/getpass.c
+++ b/misc/getpass.c
@@ -91,7 +91,7 @@ getpass (prompt)
 
   /* Write the prompt.  */
   __fxprintf (out, "%s", prompt);
-  fflush_unlocked (out);
+  __fflush_unlocked (out);
 
   /* Read the password.  */
   nread = __getline (&buf, &bufsize, in);

-- 
Joseph S. Myers
joseph@codesourcery.com


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