From 3248e3a326e04320d0fdecba70be17d4f13bfb27 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 4 Jul 2000 18:24:11 +0000 Subject: Update. 2000-07-04 Ulrich Drepper * crypt/md5-crypt.c (__md5_crypt_r): If buffers for key and salt are not aligned to alignof(md5_uint32) do it before calling __md5_process_bytes. * crypt/md5.c: Make sure buffers are aligned. * crypt/md5.h: Likewise. Reported by Solar Designer . * crypt/Makefile: Add dependencies for test programs. * Rules: Define LC_ALL=C in environments of all programs we run. * intl/tst-gettext.sh (LC_ALL): Define to C and export. 2000-07-03 H.J. Lu * locale/programs/ld-ctype.c (ctype_output): The size of iov is 2 + elem + offset, not 2 + elem + offset + 2. 2000-07-04 Ulrich Drepper * posix/fnmatch_loop.c: Fix two problems uncovered by the new test suite. * posix/Makefile (tests): Add tst-fnmatch. (tst-fnmatch-ENV): Define. * posix/tst-fnmatch.c: New file. * posix/tst-fnmatch.sh: New file. --- crypt/md5-crypt.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'crypt/md5-crypt.c') diff --git a/crypt/md5-crypt.c b/crypt/md5-crypt.c index 126103503c..3b20ed157d 100644 --- a/crypt/md5-crypt.c +++ b/crypt/md5-crypt.c @@ -1,5 +1,5 @@ /* One way encryption based on MD5 sum. - Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -18,6 +18,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include #include #include @@ -37,9 +38,9 @@ static const char b64t[64] = /* Prototypes for local functions. */ -extern char *__md5_crypt_r __P ((const char *key, const char *salt, - char *buffer, int buflen)); -extern char *__md5_crypt __P ((const char *key, const char *salt)); +extern char *__md5_crypt_r (const char *key, const char *salt, + char *buffer, int buflen); +extern char *__md5_crypt (const char *key, const char *salt); /* This entry point is equivalent to the `crypt' function in Unix @@ -51,7 +52,8 @@ __md5_crypt_r (key, salt, buffer, buflen) char *buffer; int buflen; { - unsigned char alt_result[16]; + unsigned char alt_result[16] + __attribute__ ((__aligned__ (__alignof__ (md5_uint32)))); struct md5_ctx ctx; struct md5_ctx alt_ctx; size_t salt_len; @@ -68,6 +70,24 @@ __md5_crypt_r (key, salt, buffer, buflen) salt_len = MIN (strcspn (salt, "$"), 8); key_len = strlen (key); + if ((key - (char *) 0) % __alignof__ (md5_uint32) != 0) + { + char *tmp = (char *) alloca (key_len + __alignof__ (md5_uint32)); + key = memcpy (tmp + __alignof__ (md5_uint32) + - (tmp - (char *) 0) % __alignof__ (md5_uint32), + key, key_len); + assert ((key - (char *) 0) % __alignof__ (md5_uint32) == 0); + } + + if ((salt - (char *) 0) % __alignof__ (md5_uint32) != 0) + { + char *tmp = (char *) alloca (salt_len + __alignof__ (md5_uint32)); + salt = memcpy (tmp + __alignof__ (md5_uint32) + - (tmp - (char *) 0) % __alignof__ (md5_uint32), + salt, salt_len); + assert ((salt - (char *) 0) % __alignof__ (md5_uint32) == 0); + } + /* Prepare for the real work. */ __md5_init_ctx (&ctx); -- cgit v1.2.1