Skip to content

Commit

Permalink
hashfn: fix inconsistencies on big-endian architectures (#3979)
Browse files Browse the repository at this point in the history
The computation of the SuperFashHash function did assume that the code
was run on a little-endian machine, causing a different result when it's
run on a big-endian machine.

This patch explicitly accesses the memory using little-endian mode to
keep backwards compatibility but to produce the same result on
big-endian architectures.

Fixes: #3345

Signed-off-by: Xavi Hernandez <xhernandez@gmail.com>
  • Loading branch information
xhernandez committed Mar 27, 2023
1 parent a54e44e commit 5d8be93
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libglusterfs/src/hashfn.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <endian.h>
#endif

#define get16bits(d) (*((const uint16_t *)(d)))
#define get16bits(d) le16toh(*((const uint16_t *)(d)))

#define DM_DELTA 0x9E3779B9
#define DM_FULLROUNDS 10 /* 32 is overkill, 16 is strong crypto */
Expand Down

0 comments on commit 5d8be93

Please sign in to comment.