summaryrefslogtreecommitdiff
path: root/libiberty
diff options
context:
space:
mode:
authorsje <sje@138bc75d-0d04-0410-961f-82ee72b054a4>2005-07-03 15:40:29 +0000
committersje <sje@138bc75d-0d04-0410-961f-82ee72b054a4>2005-07-03 15:40:29 +0000
commitd01e2a38695cf484eacdc8de0addf1a6891fce14 (patch)
treee972d666334ce85e6dc741fe56d68641f7b6659c /libiberty
parent91fc5678cae1e7421e46e1e0af32c91a41b65aa1 (diff)
downloadgcc-d01e2a38695cf484eacdc8de0addf1a6891fce14.tar.gz
PR other/13906
* md5.c (md5_process_bytes): Check alignment. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@101557 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libiberty')
-rw-r--r--libiberty/ChangeLog5
-rw-r--r--libiberty/md5.c17
2 files changed, 22 insertions, 0 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index eb19aa71e4c..ba575549ada 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,8 @@
+2005-07-03 Steve Ellcey <sje@cup.hp.com>
+
+ PR other/13906
+ * md5.c (md5_process_bytes): Check alignment.
+
2005-07-01 Ian Lance Taylor <ian@airs.com>
PR other/22268
diff --git a/libiberty/md5.c b/libiberty/md5.c
index c03a74dffa2..83e0beb339f 100644
--- a/libiberty/md5.c
+++ b/libiberty/md5.c
@@ -223,6 +223,23 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
/* Process available complete blocks. */
if (len > 64)
{
+#if !_STRING_ARCH_unaligned
+/* To check alignment gcc has an appropriate operator. Other
+ compilers don't. */
+# if __GNUC__ >= 2
+# define UNALIGNED_P(p) (((md5_uintptr) p) % __alignof__ (md5_uint32) != 0)
+# else
+# define UNALIGNED_P(p) (((md5_uintptr) p) % sizeof (md5_uint32) != 0)
+# endif
+ if (UNALIGNED_P (buffer))
+ while (len > 64)
+ {
+ md5_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
+ buffer = (const char *) buffer + 64;
+ len -= 64;
+ }
+ else
+#endif
md5_process_block (buffer, len & ~63, ctx);
buffer = (const void *) ((const char *) buffer + (len & ~63));
len &= 63;