about summary refs log tree commit diff
path: root/crypt/sha256-crypt.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2016-11-16 22:46:48 +0000
committerJoseph Myers <joseph@codesourcery.com>2016-11-16 22:46:48 +0000
commit61158ffa9a17476d88aaf4a833d13b12f1c51387 (patch)
tree2113e63413caa6d97c0e9bf0b905afbfd4a7eee0 /crypt/sha256-crypt.c
parent7773556dfb2bf62f7b6deda66fa3821a3bcdbf3e (diff)
downloadglibc-61158ffa9a17476d88aaf4a833d13b12f1c51387.tar.gz
glibc-61158ffa9a17476d88aaf4a833d13b12f1c51387.tar.xz
glibc-61158ffa9a17476d88aaf4a833d13b12f1c51387.zip
Fix crypt snprintf namespace (bug 20829).
Extending linknamespace tests to cover libcrypt showed that crypt
brings in references to snprintf, but is in XPG3 and XPG4 which don't
have snprintf.  This patch fixes it to use __snprintf instead,
exporting __snprintf from libc.so at version GLIBC_PRIVATE and adding
libc_hidden_proto / libc_hidden_def accordingly.

Tested for x86_64 and x86, in conjunction with the testsuite changes
to enable linknamespace testing for libdl and libcrypt.  Also tested
(compilation only) for powerpc to make sure there were no problem
interactions with the optional-long-double handling for snprintf.

	[BZ #20829]
	* stdio-common/Versions (__snprintf): Add to version
	GLIBC_PRIVATE.
	* include/stdio.h (__snprintf): Use libc_hidden_proto.
	* stdio-common/snprintf.c (__snprintf): Use libc_hidden_def.
	* crypt/sha256-crypt.c (__sha256_crypt_r): Use __snprintf instead
	of snprintf.
	* crypt/sha512-crypt.c (__sha512_crypt_r): Likewise.
Diffstat (limited to 'crypt/sha256-crypt.c')
-rw-r--r--crypt/sha256-crypt.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/crypt/sha256-crypt.c b/crypt/sha256-crypt.c
index ca703dec6d..d768234879 100644
--- a/crypt/sha256-crypt.c
+++ b/crypt/sha256-crypt.c
@@ -319,8 +319,8 @@ __sha256_crypt_r (const char *key, const char *salt, char *buffer, int buflen)
 
   if (rounds_custom)
     {
-      int n = snprintf (cp, MAX (0, buflen), "%s%zu$",
-			sha256_rounds_prefix, rounds);
+      int n = __snprintf (cp, MAX (0, buflen), "%s%zu$",
+			  sha256_rounds_prefix, rounds);
       cp += n;
       buflen -= n;
     }