2000-07-04  Ulrich Drepper  <drepper@redhat.com>

	* 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 <solar@false.com>.

	* 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  <hjl@gnu.org>

	* 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  <drepper@redhat.com>

	* 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.
This commit is contained in:
Ulrich Drepper 2000-07-04 18:24:11 +00:00
parent 83b1b6d8fa
commit 3248e3a326
6 changed files with 93 additions and 19 deletions

View File

@ -1,3 +1,32 @@
2000-07-04 Ulrich Drepper <drepper@redhat.com>
* 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 <solar@false.com>.
* 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 <hjl@gnu.org>
* 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 <drepper@redhat.com>
* 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.
2000-07-04 NIIBE Yutaka <gniibe@chroot.org>
* locale/programs/charmap.c (charmap_read): Prepend
@ -21,6 +50,7 @@
Wrap extern symbols in BP_SYM ().
2000-07-03 Andreas Jaeger <aj@suse.de>
* dlfcn/Makefile (generated): New.
2000-07-03 Ulrich Drepper <drepper@redhat.com>

4
Rules
View File

@ -119,10 +119,10 @@ ifneq "$(strip $(tests) $(test-srcs))" ""
# These are the implicit rules for making test outputs
# from the test programs and whatever input files are present.
$(objpfx)%.out: %.input $(objpfx)%
GCONV_PATH=$(common-objpfx)iconvdata \
GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
$($*-ENV) $(built-program-cmd) $($*-ARGS) < $(word 1,$^) > $@
$(objpfx)%.out: /dev/null $(objpfx)% # Make it 2nd arg for canned sequence.
GCONV_PATH=$(common-objpfx)iconvdata \
GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
$($*-ENV) $(built-program-cmd) $($*-ARGS) > $@
endif # tests

View File

@ -45,8 +45,17 @@ $(objpfx)md5test: $(objpfx)md5.o
include ../Rules
LDLIBS-cert = crypt/libcrypt
LDLIBS-md5c-test = crypt/libcrypt
LDLIBS-cert = libcrypt
LDLIBS-md5c-test = libcrypt
ifeq (yes,$(build-shared))
libcrypt-dep = $(objpfx)libcrypt.so
else
libcrypt-dep = $(objpfx)libcrypt.a
endif
$(objpfx)cert.out: $(libcrypt-dep)
$(objpfx)md5c-test.out: $(libcrypt-dep)
# Depend on libc.so so a DT_NEEDED is generated in the shared objects.
# This ensures they will load libc.so for needed symbols if loaded by

View File

@ -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 <drepper@cygnus.com>, 1996.
@ -18,6 +18,7 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
@ -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);

View File

@ -1,6 +1,6 @@
/* md5.c - Functions to compute MD5 message digest of files or memory blocks
/* Functions to compute MD5 message digest of files or memory blocks.
according to the definition of MD5 in RFC 1321 from April 1992.
Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
Copyright (C) 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@ -217,6 +217,8 @@ md5_process_bytes (buffer, len, ctx)
size_t len;
struct md5_ctx *ctx;
{
//const void aligned_buffer = buffer;
/* When we already have some bits in our internal buffer concatenate
both inputs first. */
if (ctx->buflen != 0)
@ -224,16 +226,20 @@ md5_process_bytes (buffer, len, ctx)
size_t left_over = ctx->buflen;
size_t add = 128 - left_over > len ? len : 128 - left_over;
/* Only put full words in the buffer. */
add -= add % __alignof__ (md5_uint32);
memcpy (&ctx->buffer[left_over], buffer, add);
ctx->buflen += add;
if (left_over + add > 64)
if (ctx->buflen > 64)
{
md5_process_block (ctx->buffer, (left_over + add) & ~63, ctx);
md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
ctx->buflen &= 63;
/* The regions in the following copy operation cannot overlap. */
memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63],
(left_over + add) & 63);
ctx->buflen = (left_over + add) & 63;
ctx->buflen);
}
buffer = (const char *) buffer + add;
@ -251,8 +257,17 @@ md5_process_bytes (buffer, len, ctx)
/* Move remaining bytes in internal buffer. */
if (len > 0)
{
memcpy (ctx->buffer, buffer, len);
ctx->buflen = len;
size_t left_over = ctx->buflen;
memcpy (&ctx->buffer[left_over], buffer, len);
left_over += len;
if (left_over >= 64)
{
md5_process_block (ctx->buffer, 64, ctx);
left_over -= 64;
memcpy (ctx->buffer, &ctx->buffer[64], left_over);
}
ctx->buflen = left_over;
}
}

View File

@ -1,6 +1,6 @@
/* Declaration of functions and data types used for MD5 sum computing
library functions.
Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
Copyright (C) 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@ -87,7 +87,7 @@ struct md5_ctx
md5_uint32 total[2];
md5_uint32 buflen;
char buffer[128];
char buffer[128] __attribute__ ((__aligned__ (__alignof__ (md5_uint32))));
};
/*