[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] [sharutils] Fix swapping on big-endian machines
From: |
Petr Písař |
Subject: |
[PATCH] [sharutils] Fix swapping on big-endian machines |
Date: |
Thu, 3 Jan 2013 17:30:02 +0100 |
4.13.1 release replaced SWAP() macro with function. However there were
two bugs. First the function always retuned 0 because it ignored
input argument. Second it indexed input array off-by-one. As
result, shar-1 test failed on S390 or PPC.
This patch fixes it.
---
lib/md5.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/lib/md5.c b/lib/md5.c
index 076f6ef..6dea827 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -54,10 +54,11 @@ SWAP(md5_uint32 n)
md5_uint32 uiv;
} v, res;
- res.cv[0] = v.cv[sizeof(md5_uint32) - 0];
- res.cv[1] = v.cv[sizeof(md5_uint32) - 1];
- res.cv[2] = v.cv[sizeof(md5_uint32) - 2];
- res.cv[3] = v.cv[sizeof(md5_uint32) - 3];
+ v.uiv = n;
+ res.cv[0] = v.cv[sizeof(md5_uint32) - 1];
+ res.cv[1] = v.cv[sizeof(md5_uint32) - 2];
+ res.cv[2] = v.cv[sizeof(md5_uint32) - 3];
+ res.cv[3] = v.cv[sizeof(md5_uint32) - 4];
return res.uiv;
}
--
1.7.11.7
- [PATCH] [sharutils] Fix swapping on big-endian machines,
Petr Písař <=