fix for sparc

This commit is contained in:
Tom Callaway 2008-05-30 00:26:38 +00:00
parent 26314cd521
commit 8738c500a0
2 changed files with 70 additions and 1 deletions

View File

@ -0,0 +1,64 @@
diff -up coreutils-6.11/lib/sha256.c.sparc coreutils-6.11/lib/sha256.c
--- coreutils-6.11/lib/sha256.c.sparc 2008-04-19 16:34:23.000000000 -0500
+++ coreutils-6.11/lib/sha256.c 2008-05-29 18:48:56.000000000 -0500
@@ -134,9 +134,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.11/lib/sha512.c.sparc coreutils-6.11/lib/sha512.c
--- coreutils-6.11/lib/sha512.c.sparc 2008-04-19 16:34:23.000000000 -0500
+++ coreutils-6.11/lib/sha512.c 2008-05-29 18:40:36.000000000 -0500
@@ -141,10 +141,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.11/src/Makefile.am.sparc coreutils-6.11/src/Makefile.am
--- coreutils-6.11/src/Makefile.am.sparc 2008-04-19 16:34:23.000000000 -0500
+++ coreutils-6.11/src/Makefile.am 2008-05-29 18:40:36.000000000 -0500
@@ -101,6 +101,7 @@ shred_LDADD = $(LDADD) $(LIB_GETHRXTIME)
shuf_LDADD = $(LDADD) $(LIB_GETHRXTIME)
tac_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
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.11/src/Makefile.in.sparc coreutils-6.11/src/Makefile.in
--- coreutils-6.11/src/Makefile.in.sparc 2008-04-19 16:50:10.000000000 -0500
+++ coreutils-6.11/src/Makefile.in 2008-05-29 18:40:36.000000000 -0500
@@ -1251,6 +1251,7 @@ shuf_LDADD = $(LDADD) $(LIB_GETHRXTIME)
tac_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
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)

View File

@ -1,7 +1,7 @@
Summary: The GNU core utilities: a set of tools commonly used in shell scripts
Name: coreutils
Version: 6.11
Release: 4%{?dist}
Release: 5%{?dist}
License: GPLv3+
Group: System Environment/Base
Url: http://www.gnu.org/software/coreutils/
@ -26,6 +26,7 @@ Patch102: coreutils-6.10-manpages.patch
#Patch103: coreutils-6.10-longoptions.patch
Patch104: coreutils-idcontext.patch
Patch105: coreutils-testnonenglish.patch
Patch106: coreutils-6.11-sparc-shafix.patch
# sh-utils
Patch703: sh-utils-2.0.11-dateman.patch
@ -107,6 +108,7 @@ cd %name-%version
#%patch103 -p1 -b .longopt
%patch104 -p1 -b .idcontext
%patch105 -p1 -b .noneng
%patch106 -p1 -b .sparc
# sh-utils
%patch703 -p1 -b .dateman
@ -310,6 +312,9 @@ fi
/sbin/runuser
%changelog
* Thu May 29 2008 Tom "spot" Callaway <tcallawa@redhat.com> - 6.11-5
- fix SHA256/SHA512 to work on sparc
* Tue May 20 2008 Ondrej Vasik <ovasik@redhat.com> - 6.11-4
- fixed a HUGE memory leak in install binary(#447410)