]> git.pld-linux.org Git - packages/tla.git/blobdiff - 0002-Fixes-alignment-errors-on-hppa-and-sparc.patch
- fixes from Debian
[packages/tla.git] / 0002-Fixes-alignment-errors-on-hppa-and-sparc.patch
diff --git a/0002-Fixes-alignment-errors-on-hppa-and-sparc.patch b/0002-Fixes-alignment-errors-on-hppa-and-sparc.patch
new file mode 100644 (file)
index 0000000..6a90e68
--- /dev/null
@@ -0,0 +1,98 @@
+From: Martín Ferrari <martin.ferrari@gmail.com>
+Date: Mon, 28 Aug 2006 07:06:06 +0200
+Subject: Fixes alignment errors on hppa and sparc.
+
+Bug-Debian: http://bugs.debian.org/382465
+---
+ src/hackerlab/hash/sha1.c |   25 ++++++++++++++++---------
+ 1 files changed, 16 insertions(+), 9 deletions(-)
+
+diff --git a/src/hackerlab/hash/sha1.c b/src/hackerlab/hash/sha1.c
+index 47a7352..00556d4 100644
+--- a/src/hackerlab/hash/sha1.c
++++ b/src/hackerlab/hash/sha1.c
+@@ -39,11 +39,11 @@ struct sha1_context
+   t_uint32 total[2];
+   t_uint32 buflen;
+-  t_uchar buffer[128];
++  t_uchar buffer[128] __attribute__((aligned(4)));
+ };
+ static void
+-sha1_process_blocks (const void *buffer, size_t len, sha1_context_t ctx);
++sha1_process_blocks (const t_uchar *buffer, size_t len, sha1_context_t ctx);
+ #if MACHINE_IS_BIGENDIAN
+ # define NOTSWAP(n) (n)
+@@ -124,7 +124,7 @@ sha1_scan (sha1_context_t ctx, const t_uchar *buffer, size_t len)
+ {
+   /* When we already have some bits in our internal buffer concatenate
+      both inputs first.  */
+-  if (ctx->buflen != 0)
++  while (len > 0)
+     {
+       size_t left_over = ctx->buflen;
+       size_t add = 128 - left_over > len ? len : 128 - left_over;
+@@ -147,14 +147,17 @@ sha1_scan (sha1_context_t ctx, const t_uchar *buffer, size_t len)
+     }
+   /* Process available complete blocks.  */
++  /*
+   if (len >= 64)
+     {
+       sha1_process_blocks (buffer, len & ~63, ctx);
+       buffer = (const t_uchar *) buffer + (len & ~63);
+       len &= 63;
+     }
++  */
+   /* Move remaining bytes in internal buffer.  */
++  /*
+   if (len > 0)
+     {
+       size_t left_over = ctx->buflen;
+@@ -169,6 +172,7 @@ sha1_scan (sha1_context_t ctx, const t_uchar *buffer, size_t len)
+       }
+       ctx->buflen = left_over;
+     }
++  */
+ }
+@@ -191,6 +195,8 @@ sha1_final (t_uchar *result, sha1_context_t ctx)
+   /* Take yet unprocessed bytes into account.  */
+   t_uint32 bytes = ctx->buflen;
+   size_t pad;
++  /* Temporary array for solving alignment issues */
++  t_uint32 tmp[5];
+   /* Now count remaining bytes.  */
+   ctx->total[0] += bytes;
+@@ -208,11 +214,12 @@ sha1_final (t_uchar *result, sha1_context_t ctx)
+   /* Process last bytes.  */
+   sha1_process_blocks (ctx->buffer, bytes + pad + 8, ctx);
+-  ((t_uint32 *) result)[0] = NOTSWAP (ctx->current_sha1.A);
+-  ((t_uint32 *) result)[1] = NOTSWAP (ctx->current_sha1.B);
+-  ((t_uint32 *) result)[2] = NOTSWAP (ctx->current_sha1.C);
+-  ((t_uint32 *) result)[3] = NOTSWAP (ctx->current_sha1.D);
+-  ((t_uint32 *) result)[4] = NOTSWAP (ctx->current_sha1.E);
++  tmp[0] = NOTSWAP (ctx->current_sha1.A);
++  tmp[1] = NOTSWAP (ctx->current_sha1.B);
++  tmp[2] = NOTSWAP (ctx->current_sha1.C);
++  tmp[3] = NOTSWAP (ctx->current_sha1.D);
++  tmp[4] = NOTSWAP (ctx->current_sha1.E);
++  mem_cpy (result, tmp, 20);
+   
+   sha1_context_reset (ctx);
+ }
+@@ -329,7 +336,7 @@ sha1_from_ascii (sha1_t * out, t_uchar const * ascii)
+    It is assumed that LEN % 64 == 0.
+    Most of this code comes from GnuPG's cipher/sha1.c.  */
+ static void
+-sha1_process_blocks (const void *buffer, size_t len, sha1_context_t ctx)
++sha1_process_blocks (const t_uchar *buffer, size_t len, sha1_context_t ctx)
+ {
+   const t_uint32 *words = buffer;
+   size_t nwords = len / sizeof (t_uint32);
This page took 0.080275 seconds and 4 git commands to generate.