Fix syslog dprintf namespace (bug 18534)
Joseph Myers
joseph@codesourcery.com
Mon Jun 15 08:02:00 GMT 2015
syslog functions bring in references to dprintf, which wasn't added to
POSIX until the 2008 edition and so isn't in various standards
containing the syslog functions. This patch fixes this by making
dprintf into a weak alias of __dprintf and using __dprintf as
appropriate.
Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch).
2015-06-14 Joseph Myers <joseph@codesourcery.com>
[BZ #18534]
* stdio-common/dprintf.c (__dprintf): Use libc_hidden_def.
(dprintf): Define as a weak alias of __dprintf, not a strong
alias.
* include/stdio.h (__dprintf): Declare. Use libc_hidden_proto.
* misc/syslog.c (__vsyslog_chk): Call __dprintf instead of
dprintf.
* conform/Makefile (test-xfail-XPG4/syslog.h/linknamespace):
Remove variable.
(test-xfail-UNIX98/syslog.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/syslog.h/linknamespace): Likewise.
diff --git a/conform/Makefile b/conform/Makefile
index 567046f..9347b0f 100644
--- a/conform/Makefile
+++ b/conform/Makefile
@@ -346,16 +346,13 @@ test-xfail-XOPEN2K8/ndbm.h/linknamespace = yes
# Unsorted expected failures.
test-xfail-XPG3/unistd.h/linknamespace = yes
test-xfail-XPG4/fmtmsg.h/linknamespace = yes
-test-xfail-XPG4/syslog.h/linknamespace = yes
test-xfail-XPG4/unistd.h/linknamespace = yes
test-xfail-POSIX/mqueue.h/linknamespace = yes
test-xfail-POSIX/semaphore.h/linknamespace = yes
test-xfail-UNIX98/fmtmsg.h/linknamespace = yes
test-xfail-UNIX98/mqueue.h/linknamespace = yes
-test-xfail-UNIX98/syslog.h/linknamespace = yes
test-xfail-UNIX98/unistd.h/linknamespace = yes
test-xfail-UNIX98/wchar.h/linknamespace = yes
test-xfail-XOPEN2K/fmtmsg.h/linknamespace = yes
-test-xfail-XOPEN2K/syslog.h/linknamespace = yes
test-xfail-POSIX2008/semaphore.h/linknamespace = yes
test-xfail-XOPEN2K8/fmtmsg.h/linknamespace = yes
diff --git a/include/stdio.h b/include/stdio.h
index 6ae70a3..9cd324b 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -135,6 +135,9 @@ extern int _IO_new_fgetpos (_IO_FILE *, _IO_fpos_t *);
# endif
libc_hidden_proto (dprintf)
+extern __typeof (dprintf) __dprintf
+ __attribute__ ((__format__ (__printf__, 2, 3)));
+libc_hidden_proto (__dprintf)
libc_hidden_proto (fprintf)
libc_hidden_proto (vfprintf)
libc_hidden_proto (sprintf)
diff --git a/misc/syslog.c b/misc/syslog.c
index 35cae6c..9dd4cde 100644
--- a/misc/syslog.c
+++ b/misc/syslog.c
@@ -298,7 +298,7 @@ __vsyslog_chk(int pri, int flag, const char *fmt, va_list ap)
if (LogStat & LOG_CONS &&
(fd = __open(_PATH_CONSOLE, O_WRONLY|O_NOCTTY, 0)) >= 0)
{
- dprintf (fd, "%s\r\n", buf + msgoff);
+ __dprintf (fd, "%s\r\n", buf + msgoff);
(void)__close(fd);
}
}
diff --git a/stdio-common/dprintf.c b/stdio-common/dprintf.c
index 3221cf0..5a7011d 100644
--- a/stdio-common/dprintf.c
+++ b/stdio-common/dprintf.c
@@ -35,5 +35,6 @@ __dprintf (int d, const char *format, ...)
return done;
}
+libc_hidden_def (__dprintf)
ldbl_hidden_def (__dprintf, dprintf)
-ldbl_strong_alias (__dprintf, dprintf)
+ldbl_weak_alias (__dprintf, dprintf)
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Libc-alpha
mailing list