]> sourceware.org Git - glibc.git/commitdiff
Fix crypt snprintf namespace (bug 20829).
authorJoseph Myers <joseph@codesourcery.com>
Wed, 16 Nov 2016 22:46:48 +0000 (22:46 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Wed, 16 Nov 2016 22:46:48 +0000 (22:46 +0000)
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.

ChangeLog
crypt/sha256-crypt.c
crypt/sha512-crypt.c
include/stdio.h
stdio-common/Versions
stdio-common/snprintf.c

index 25e1da152ad850806519e17d115c8f4f4891240b..49e0ae7fedf95df027e60108c6cf3761cbcf7be9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2016-11-16  Joseph Myers  <joseph@codesourcery.com>
+
+       [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.
+
 2016-11-16  Zack Weinberg  <zackw@panix.com>
 
        * string/string.h: Remove obsolete comment stating that
index ca703dec6d465cadb554943ce72f496950fb0d48..d768234879c40a4d0f5acd80d4c0606f3a8ad64b 100644 (file)
@@ -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;
     }
index c42e5b785d9858c54f44080a5b3d122ad5a9c207..f404c88b204debf99ecc803c8103fe4a929382df 100644 (file)
@@ -318,8 +318,8 @@ __sha512_crypt_r (const char *key, const char *salt, char *buffer, int buflen)
 
   if (rounds_custom)
     {
-      int n = snprintf (cp, MAX (0, buflen), "%s%zu$",
-                       sha512_rounds_prefix, rounds);
+      int n = __snprintf (cp, MAX (0, buflen), "%s%zu$",
+                         sha512_rounds_prefix, rounds);
       cp += n;
       buflen -= n;
     }
index 1ffbc40b3dd4990ea02ede61e6c55c81ff807e21..30e737efc2be6ba518f1c8b2d0f40076a96923ba 100644 (file)
@@ -11,6 +11,7 @@ extern int __fcloseall (void);
 extern int __snprintf (char *__restrict __s, size_t __maxlen,
                       const char *__restrict __format, ...)
      __attribute__ ((__format__ (__printf__, 3, 4)));
+libc_hidden_proto (__snprintf)
 extern int __vsnprintf (char *__restrict __s, size_t __maxlen,
                        const char *__restrict __format, _G_va_list __arg)
      __attribute__ ((__format__ (__printf__, 3, 0)));
index 06b96f678a42d608087a8c72ba00f0a7b738c64e..5016f69c206d49237b69355f823294946a9058c8 100644 (file)
@@ -60,5 +60,7 @@ libc {
   GLIBC_PRIVATE {
     # global variables
     _itoa_lower_digits;
+    # Used in libcrypt.
+    __snprintf;
   }
 }
index a3cc51897692d5cd1718b2d3faa24a2c8165d6ec..ce7ce060773ce3d871211f858813cebfc9e3f9c6 100644 (file)
@@ -35,4 +35,5 @@ __snprintf (char *s, size_t maxlen, const char *format, ...)
 
   return done;
 }
+libc_hidden_def (__snprintf)
 ldbl_weak_alias (__snprintf, snprintf)
This page took 0.155125 seconds and 5 git commands to generate.