diff options
author | Zack Weinberg <zackw@panix.com> | 2017-09-16 10:36:23 -0400 |
---|---|---|
committer | Zack Weinberg <zackw@panix.com> | 2017-09-16 10:44:54 -0400 |
commit | f05dbd4f208df9e8f93f0a8e76a9d07514c08522 (patch) | |
tree | 0a82c14734ffbb5e5e6c0017c765f608d83f4470 /crypt.c | |
parent | 213165de9a7154506ee87cb0d1286eaebbf6bba7 (diff) | |
download | libxcrypt-f05dbd4f208df9e8f93f0a8e76a9d07514c08522.tar.gz libxcrypt-f05dbd4f208df9e8f93f0a8e76a9d07514c08522.tar.bz2 libxcrypt-f05dbd4f208df9e8f93f0a8e76a9d07514c08522.zip |
Reintroduce semi-automated namespace cleanliness.
All of the internal symbols that can't be 'static' in a single file
are now renamed with a _crypt_ prefix by macros in crypt-symbols.h.
The list of these macros must be maintained by hand, but there is a
test program (test-symbols.sh) that verifies it. Essentially, all
global symbols in the static library (libcrypt.a) must either appear
in a "global:" block in libcrypt.map, or they must begin with _crypt_.
It also checks that every "global:" symbol declared in libcrypt.map is
exported from the static library.
This reminded me that two API symbols should never have existed in the
first place (bigcrypt_r, crypt_gensalt_r) and one had gotten dropped
by accident (fcrypt).
Due to limitations in Automake, invoking the new test script by hand
is a little awkward (it takes arguments from the environment) and the
C programs used only for testing are now part of check_PROGRAMS, not
noinst_PROGRAMS, which means they are no longer built by 'make all'.
* crypt-obsolete.h (bigcrypt_r): Remove declaration.
* crypt.h (crypt_gensalt_r): Remove declaration.
* libcrypt.map (crypt_gensalt_r, bigcrypt_r): Remove.
* crypt-symbols.h: Correct multiple-inclusion guard.
Add macros that rename all internal global symbols.
Add new symbol-hacking macro 'strong_alias'.
* crypt.c (crypt_gensalt_r): Delete.
(bigcrypt_r): Fold body into bigcrypt and delete.
(fcrypt): Define as strong alias of crypt.
* test-gensalt.c: Use crypt_gensalt_rn, not crypt_gensalt_r.
* test-symbols.sh: New test.
* Makefile.am (noinst_PROGRAMS): Just alg-des-mktables.
(check_PROGRAMS): All C tests are here now.
(TESTS): Add test-symbols.sh.
(AM_TESTS_ENVIRONMENT): Provide arguments for test-symbols.sh.
Diffstat (limited to 'crypt.c')
-rw-r--r-- | crypt.c | 31 |
1 files changed, 10 insertions, 21 deletions
@@ -191,6 +191,7 @@ crypt (const char *key, const char *salt) { return crypt_r (key, salt, &nr_crypt_ctx); } +strong_alias(crypt, fcrypt); char * crypt_gensalt_rn (const char *prefix, unsigned long count, @@ -216,13 +217,6 @@ crypt_gensalt_rn (const char *prefix, unsigned long count, } char * -crypt_gensalt_r (const char *prefix, unsigned long count, - const char *input, int size, char *output, int output_size) -{ - return crypt_gensalt_rn (prefix, count, input, size, output, output_size); -} - -char * crypt_gensalt_ra (const char *prefix, unsigned long count, const char *input, int size) { @@ -244,22 +238,17 @@ crypt_gensalt (const char *prefix, unsigned long count, input, size, output, sizeof (output)); } -/* Obsolete interfaces - not to be used in new code. These are the - same as crypt_r and crypt, but they force the use of the Digital - Unix "bigcrypt" hash, which is nearly as weak as traditional DES. */ +/* Obsolete interface - not to be used in new code. This function is + the same as crypt, but it forces the use of the Digital Unix + "bigcrypt" hash, which is nearly as weak as traditional DES. + Because it is obsolete, we have not added a reentrant version. */ char * -bigcrypt_r (const char *key, const char *salt, - struct crypt_data *restrict data) +bigcrypt (const char *key, const char *salt) { - char *retval = crypt_des_big_rn (key, salt, (char *) data, sizeof (*data)); + char *retval = crypt_des_big_rn + (key, salt, (char *)&nr_crypt_ctx, sizeof nr_crypt_ctx); if (retval) return retval; - make_failure_token (salt, (char *)data, sizeof (*data)); - return (char *)data; -} - -char * -bigcrypt (const char *key, const char *salt) -{ - return bigcrypt_r (key, salt, &nr_crypt_ctx); + make_failure_token (salt, (char *)&nr_crypt_ctx, sizeof nr_crypt_ctx); + return (char *)&nr_crypt_ctx; } |