4482191
diff -up coreutils-6.10/lib/sha256.c.sparc coreutils-6.10/lib/sha256.c
4482191
--- coreutils-6.10/lib/sha256.c.sparc	2007-11-25 08:23:31.000000000 -0500
4482191
+++ coreutils-6.10/lib/sha256.c	2008-05-29 15:57:56.000000000 -0400
4482191
@@ -85,6 +85,15 @@ sha224_init_ctx (struct sha256_ctx *ctx)
4482191
   ctx->buflen = 0;
4482191
 }
4482191
 
4482191
+/* Copy the value from v into the memory location pointed to by *cp,
4482191
+   If your architecture allows unaligned access this is equivalent to
4482191
+   * (uint32_t *) cp = v  */
4482191
+static inline void
4482191
+set_uint32 (char *cp, uint32_t v)
4482191
+{
4482191
+  memcpy (cp, &v, sizeof v);
4482191
+}
4482191
+
4482191
 /* Put result from CTX in first 32 bytes following RESBUF.  The result
4482191
    must be in little endian byte order.
4482191
 
4482191
@@ -129,9 +138,13 @@ sha256_conclude_ctx (struct sha256_ctx *
4482191
   if (ctx->total[0] < bytes)
4482191
     ++ctx->total[1];
4482191
 
4482191
-  /* Put the 64-bit file length in *bits* at the end of the buffer.  */
4482191
-  ctx->buffer[size - 2] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
4482191
-  ctx->buffer[size - 1] = SWAP (ctx->total[0] << 3);
4482191
+  /* Put the 64-bit file length in *bits* at the end of the buffer.
4482191
+     Use set_uint32 rather than a simple assignment, to avoid risk of
4482191
+     unaligned access.  */
4482191
+  set_uint32 ((char *) &ctx->buffer[size - 2],
4482191
+             SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29)));
4482191
+  set_uint32 ((char *) &ctx->buffer[size - 1],
4482191
+             SWAP (ctx->total[0] << 3));
4482191
 
4482191
   memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
4482191
 
4482191
diff -up coreutils-6.10/lib/sha512.c.sparc coreutils-6.10/lib/sha512.c
4482191
--- coreutils-6.10/lib/sha512.c.sparc	2007-11-25 08:23:31.000000000 -0500
4482191
+++ coreutils-6.10/lib/sha512.c	2008-05-29 15:58:49.000000000 -0400
4482191
@@ -92,6 +92,15 @@ sha384_init_ctx (struct sha512_ctx *ctx)
4482191
   ctx->buflen = 0;
4482191
 }
4482191
 
4482191
+/* Copy the value from V into the memory location pointed to by *CP,
4482191
+   If your architecture allows unaligned access, this is equivalent to
4482191
+   * (__typeof__ (v) *) cp = v  */
4482191
+static inline void
4482191
+set_uint64 (char *cp, u64 v)
4482191
+{
4482191
+  memcpy (cp, &v, sizeof v);
4482191
+}
4482191
+
4482191
 /* Put result from CTX in first 64 bytes following RESBUF.  The result
4482191
    must be in little endian byte order.
4482191
 
4482191
@@ -136,10 +145,14 @@ sha512_conclude_ctx (struct sha512_ctx *
4482191
   if (u64lt (ctx->total[0], u64lo (bytes)))
4482191
     ctx->total[1] = u64plus (ctx->total[1], u64lo (1));
4482191
 
4482191
-  /* Put the 64-bit file length in *bits* at the end of the buffer.  */
4482191
-  ctx->buffer[size - 2] = SWAP (u64or (u64shl (ctx->total[1], 3),
4482191
-				       u64shr (ctx->total[0], 61)));
4482191
-  ctx->buffer[size - 1] = SWAP (u64shl (ctx->total[0], 3));
4482191
+  /* Put the 128-bit file length in *bits* at the end of the buffer.
4482191
+     Use set_uint64 rather than a simple assignment, to avoid risk of
4482191
+     unaligned access.  */
4482191
+  set_uint64 ((char *) &ctx->buffer[size - 2],
4482191
+             SWAP (u64or (u64shl (ctx->total[1], 3),
4482191
+                          u64shr (ctx->total[0], 61))));
4482191
+  set_uint64 ((char *) &ctx->buffer[size - 1],
4482191
+             SWAP (u64shl (ctx->total[0], 3)));
4482191
 
4482191
   memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 8 - bytes);
4482191
 
4482191
diff -up coreutils-6.10/src/Makefile.am.BAD coreutils-6.10/src/Makefile.am
4482191
--- coreutils-6.10/src/Makefile.am.BAD	2008-05-29 16:42:30.000000000 -0400
4482191
+++ coreutils-6.10/src/Makefile.am	2008-05-29 16:43:00.000000000 -0400
4482191
@@ -99,6 +99,7 @@ shred_LDADD = $(LDADD) $(LIB_GETHRXTIME)
4482191
 shuf_LDADD = $(LDADD) $(LIB_GETHRXTIME)
4482191
 mktemp_LDADD = $(LDADD) $(LIB_GETHRXTIME)
4482191
 vdir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX)
4482191
+tac_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
4482191
 
4482191
 ## If necessary, add -lm to resolve use of pow in lib/strtod.c.
4482191
 sort_LDADD = $(LDADD) $(POW_LIB) $(LIB_GETHRXTIME)
4482191
diff -up coreutils-6.10/src/Makefile.in.BAD coreutils-6.10/src/Makefile.in
4482191
--- coreutils-6.10/src/Makefile.in.BAD	2008-05-29 16:43:31.000000000 -0400
4482191
+++ coreutils-6.10/src/Makefile.in	2008-05-29 16:44:03.000000000 -0400
4482191
@@ -1242,6 +1242,7 @@ shuf_LDADD = $(LDADD) $(LIB_GETHRXTIME)
4482191
 mktemp_LDADD = $(LDADD) $(LIB_GETHRXTIME)
4482191
 vdir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) $(LIB_ACL)
4482191
 sort_LDADD = $(LDADD) $(POW_LIB) $(LIB_GETHRXTIME)
4482191
+tac_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
4482191
 
4482191
 # for get_date and gettime
4482191
 date_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)