about summary refs log tree commit diff
path: root/misc/getttyent.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2015-06-17 20:21:19 +0000
committerJoseph Myers <joseph@codesourcery.com>2015-06-17 20:21:19 +0000
commitabccad04b4172d552dbdae948c0e567ba266ad76 (patch)
tree2de82b0b360a2a1003e1fe0e92c00fef92e8d79f /misc/getttyent.c
parent0595c98494c25f8eaa1a3298e8fa032ad5e4405e (diff)
downloadglibc-abccad04b4172d552dbdae948c0e567ba266ad76.tar.gz
glibc-abccad04b4172d552dbdae948c0e567ba266ad76.tar.xz
glibc-abccad04b4172d552dbdae948c0e567ba266ad76.zip
Fix ttyslot namespace (bug 18547).
ttyslot (XPG4) calls the non-XPG4 functions endttyent, getttyent and
setttyent, which in turn bring in references to fgets_unlocked and
getttynam.  This patch fixes this by making these functions into weak
aliases and calling the __* names as needed.

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

	[BZ #18547]
	* misc/getttyent.c (getttynam): Rename to __getttynam and define
	as weak alias of __getttynam.  Use prototype function definition.
	Call __setttyent, __getttyent and __endttyent instead of
	setttyent, getttyent and endttyent.
	(getttyent): Rename to __getttyent and define as weak alias of
	__getttyent.  Call __setttyent instead of setttyent.  Call
	__fgets_unlocked instead of fgets_unlocked.
	(setttyent): Rename to __setttyent and define as weak alias of
	__setttyent.
	(endttyent): Rename to __endttyent and define as weak alias of
	__endttyent.
	* include/ttyent.h (__getttyent): Declare.  Use libc_hidden_proto.
	(__setttyent): Likewise.
	(__endttyent): Likewise.
	(getttyent): Don't use libc_hidden_proto.
	(setttyent): Likewise.
	(endttyent): Likewise.
	* misc/ttyslot.c (ttyslot): Call __setttyent, __getttyent and
	__endttyent instead of setttyent, getttyent and endttyent.
	* conform/Makefile (test-xfail-XPG4/unistd.h/linknamespace):
	Remove variable.
Diffstat (limited to 'misc/getttyent.c')
-rw-r--r--misc/getttyent.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/misc/getttyent.c b/misc/getttyent.c
index 864f65f523..fcdbc2274c 100644
--- a/misc/getttyent.c
+++ b/misc/getttyent.c
@@ -44,24 +44,24 @@ static char zapchar;
 static FILE *tf;
 
 struct ttyent *
-getttynam(tty)
-	const char *tty;
+__getttynam (const char *tty)
 {
 	struct ttyent *t;
 
-	setttyent();
-	while ((t = getttyent()))
+	__setttyent();
+	while ((t = __getttyent()))
 		if (!strcmp(tty, t->ty_name))
 			break;
-	endttyent();
+	__endttyent();
 	return (t);
 }
+weak_alias (__getttynam, getttynam)
 
 static char *skip (char *) __THROW internal_function;
 static char *value (char *) __THROW internal_function;
 
 struct ttyent *
-getttyent (void)
+__getttyent (void)
 {
 	static struct ttyent tty;
 	int c;
@@ -69,11 +69,11 @@ getttyent (void)
 #define	MAXLINELENGTH	100
 	static char line[MAXLINELENGTH];
 
-	if (!tf && !setttyent())
+	if (!tf && !__setttyent())
 		return (NULL);
 	flockfile (tf);
 	for (;;) {
-		if (!fgets_unlocked(p = line, sizeof(line), tf)) {
+		if (!__fgets_unlocked(p = line, sizeof(line), tf)) {
 			funlockfile (tf);
 			return (NULL);
 		}
@@ -131,7 +131,8 @@ getttyent (void)
 		*p = '\0';
 	return (&tty);
 }
-libc_hidden_def (getttyent)
+libc_hidden_def (__getttyent)
+weak_alias (__getttyent, getttyent)
 
 #define	QUOTED	1
 
@@ -184,7 +185,7 @@ value(p)
 }
 
 int
-setttyent (void)
+__setttyent (void)
 {
 
 	if (tf) {
@@ -197,10 +198,11 @@ setttyent (void)
 	}
 	return (0);
 }
-libc_hidden_def (setttyent)
+libc_hidden_def (__setttyent)
+weak_alias (__setttyent, setttyent)
 
 int
-endttyent (void)
+__endttyent (void)
 {
 	int rval;
 
@@ -211,4 +213,5 @@ endttyent (void)
 	}
 	return (1);
 }
-libc_hidden_def (endttyent)
+libc_hidden_def (__endttyent)
+weak_alias (__endttyent, endttyent)