[master] cdd4936 make the shard sha256 extract endianness-agnostig
Nils Goroll
nils.goroll at uplex.de
Mon Sep 12 19:42:12 CEST 2016
commit cdd4936034e156ce1b3eaa8d86b70b16c6137139
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Mon Sep 12 19:40:43 2016 +0200
make the shard sha256 extract endianness-agnostig
We should have interpreted it as big endian right from the start,
but now that we got the existing code developed on little endian,
we keep it so.
diff --git a/lib/libvmod_directors/shard_hash.c b/lib/libvmod_directors/shard_hash.c
index 9fc207e..59f57e7 100644
--- a/lib/libvmod_directors/shard_hash.c
+++ b/lib/libvmod_directors/shard_hash.c
@@ -38,6 +38,7 @@
#include "vrt.h"
#include "crc32.h"
#include "vsha256.h"
+#include "vend.h"
#include "shard_parse_vcc_enums.h"
#include "shard_hash.h"
@@ -61,6 +62,7 @@ shard_hash_sha256(VCL_STRING s)
unsigned char digest[32];
uint32_t uint32_digest[8];
} sha256_digest;
+ uint32_t r;
SHA256_Init(&sha256);
SHA256_Update(&sha256, s, strlen(s));
@@ -70,7 +72,8 @@ shard_hash_sha256(VCL_STRING s)
* use low 32 bits only
* XXX: Are these the best bits to pick?
*/
- return (sha256_digest.uint32_digest[7]);
+ vle32enc(&r, sha256_digest.uint32_digest[7]);
+ return (r);
}
static uint32_t __match_proto__(hash_func)
More information about the varnish-commit
mailing list