From 44821918ee5148da684b2863070f01edecf5abda Mon Sep 17 00:00:00 2001 From: Tom Callaway Date: May 30 2008 00:26:23 +0000 Subject: fix for sparc --- diff --git a/coreutils-6.10-sparc-shafix.patch b/coreutils-6.10-sparc-shafix.patch new file mode 100644 index 0000000..2011e7c --- /dev/null +++ b/coreutils-6.10-sparc-shafix.patch @@ -0,0 +1,96 @@ +diff -up coreutils-6.10/lib/sha256.c.sparc coreutils-6.10/lib/sha256.c +--- coreutils-6.10/lib/sha256.c.sparc 2007-11-25 08:23:31.000000000 -0500 ++++ coreutils-6.10/lib/sha256.c 2008-05-29 15:57:56.000000000 -0400 +@@ -85,6 +85,15 @@ sha224_init_ctx (struct sha256_ctx *ctx) + ctx->buflen = 0; + } + ++/* Copy the value from v into the memory location pointed to by *cp, ++ If your architecture allows unaligned access this is equivalent to ++ * (uint32_t *) cp = v */ ++static inline void ++set_uint32 (char *cp, uint32_t v) ++{ ++ memcpy (cp, &v, sizeof v); ++} ++ + /* Put result from CTX in first 32 bytes following RESBUF. The result + must be in little endian byte order. + +@@ -129,9 +138,13 @@ sha256_conclude_ctx (struct sha256_ctx * + if (ctx->total[0] < bytes) + ++ctx->total[1]; + +- /* Put the 64-bit file length in *bits* at the end of the buffer. */ +- ctx->buffer[size - 2] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29)); +- ctx->buffer[size - 1] = SWAP (ctx->total[0] << 3); ++ /* Put the 64-bit file length in *bits* at the end of the buffer. ++ Use set_uint32 rather than a simple assignment, to avoid risk of ++ unaligned access. */ ++ set_uint32 ((char *) &ctx->buffer[size - 2], ++ SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29))); ++ set_uint32 ((char *) &ctx->buffer[size - 1], ++ SWAP (ctx->total[0] << 3)); + + memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes); + +diff -up coreutils-6.10/lib/sha512.c.sparc coreutils-6.10/lib/sha512.c +--- coreutils-6.10/lib/sha512.c.sparc 2007-11-25 08:23:31.000000000 -0500 ++++ coreutils-6.10/lib/sha512.c 2008-05-29 15:58:49.000000000 -0400 +@@ -92,6 +92,15 @@ sha384_init_ctx (struct sha512_ctx *ctx) + ctx->buflen = 0; + } + ++/* Copy the value from V into the memory location pointed to by *CP, ++ If your architecture allows unaligned access, this is equivalent to ++ * (__typeof__ (v) *) cp = v */ ++static inline void ++set_uint64 (char *cp, u64 v) ++{ ++ memcpy (cp, &v, sizeof v); ++} ++ + /* Put result from CTX in first 64 bytes following RESBUF. The result + must be in little endian byte order. + +@@ -136,10 +145,14 @@ sha512_conclude_ctx (struct sha512_ctx * + if (u64lt (ctx->total[0], u64lo (bytes))) + ctx->total[1] = u64plus (ctx->total[1], u64lo (1)); + +- /* Put the 64-bit file length in *bits* at the end of the buffer. */ +- ctx->buffer[size - 2] = SWAP (u64or (u64shl (ctx->total[1], 3), +- u64shr (ctx->total[0], 61))); +- ctx->buffer[size - 1] = SWAP (u64shl (ctx->total[0], 3)); ++ /* Put the 128-bit file length in *bits* at the end of the buffer. ++ Use set_uint64 rather than a simple assignment, to avoid risk of ++ unaligned access. */ ++ set_uint64 ((char *) &ctx->buffer[size - 2], ++ SWAP (u64or (u64shl (ctx->total[1], 3), ++ u64shr (ctx->total[0], 61)))); ++ set_uint64 ((char *) &ctx->buffer[size - 1], ++ SWAP (u64shl (ctx->total[0], 3))); + + memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 8 - bytes); + +diff -up coreutils-6.10/src/Makefile.am.BAD coreutils-6.10/src/Makefile.am +--- coreutils-6.10/src/Makefile.am.BAD 2008-05-29 16:42:30.000000000 -0400 ++++ coreutils-6.10/src/Makefile.am 2008-05-29 16:43:00.000000000 -0400 +@@ -99,6 +99,7 @@ shred_LDADD = $(LDADD) $(LIB_GETHRXTIME) + shuf_LDADD = $(LDADD) $(LIB_GETHRXTIME) + mktemp_LDADD = $(LDADD) $(LIB_GETHRXTIME) + vdir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) ++tac_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) + + ## If necessary, add -lm to resolve use of pow in lib/strtod.c. + sort_LDADD = $(LDADD) $(POW_LIB) $(LIB_GETHRXTIME) +diff -up coreutils-6.10/src/Makefile.in.BAD coreutils-6.10/src/Makefile.in +--- coreutils-6.10/src/Makefile.in.BAD 2008-05-29 16:43:31.000000000 -0400 ++++ coreutils-6.10/src/Makefile.in 2008-05-29 16:44:03.000000000 -0400 +@@ -1242,6 +1242,7 @@ shuf_LDADD = $(LDADD) $(LIB_GETHRXTIME) + mktemp_LDADD = $(LDADD) $(LIB_GETHRXTIME) + vdir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) $(LIB_ACL) + sort_LDADD = $(LDADD) $(POW_LIB) $(LIB_GETHRXTIME) ++tac_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) + + # for get_date and gettime + date_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) diff --git a/coreutils.spec b/coreutils.spec index 10e70a0..1f1c57d 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: The GNU core utilities: a set of tools commonly used in shell scripts Name: coreutils Version: 6.10 -Release: 23%{?dist} +Release: 24%{?dist} License: GPLv3+ Group: System Environment/Base Url: http://www.gnu.org/software/coreutils/ @@ -30,6 +30,7 @@ Patch100: coreutils-chgrp.patch Patch101: coreutils-6.10-configuration.patch Patch102: coreutils-6.10-manpages.patch #Patch103: coreutils-6.10-longoptions.patch +Patch104: coreutils-6.10-sparc-shafix.patch # sh-utils Patch703: sh-utils-2.0.11-dateman.patch @@ -115,6 +116,7 @@ cd %name-%version %patch101 -p1 -b .configure %patch102 -p1 -b .manpages #%patch103 -p1 -b .longopt +%patch104 -p1 -b .sparc # sh-utils %patch703 -p1 -b .dateman @@ -316,6 +318,9 @@ fi /sbin/runuser %changelog +* Mon May 26 2008 Tom "spot" Callaway - 6.10-24 +- fix SHA256/SHA512 to work on sparc + * Tue May 20 2008 Ondrej Vasik - 6.10-23 - fixed a HUGE memory leak in install binary(#447410)