From 2fd902f11823433ba9332da3106253b674563542 Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Thu, 18 Oct 2018 16:36:41 +0200 Subject: mkfs.ubifs: Make r5 hash binary string aware As of now all filenames known by UBIFS are strings with a NUL terminator. With encrypted filenames a filename can be any binary string and the r5 function cannot search for the NUL terminator. UBIFS always knows how long a filename is, therefore we can change the hash function to iterate over the filename length to work correctly with binary strings. Signed-off-by: Richard Weinberger Signed-off-by: David Oberhollenzer --- ubifs-utils/mkfs.ubifs/key.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'ubifs-utils') diff --git a/ubifs-utils/mkfs.ubifs/key.h b/ubifs-utils/mkfs.ubifs/key.h index c16d0a8..0c7922b 100644 --- a/ubifs-utils/mkfs.ubifs/key.h +++ b/ubifs-utils/mkfs.ubifs/key.h @@ -64,9 +64,8 @@ static inline uint32_t key_r5_hash(const char *s, int len) { uint32_t a = 0; const signed char *str = (const signed char *)s; - (void)len; - while (*str) { + while (len--) { a += *str << 4; a += *str >> 4; a *= 11; -- cgit v1.2.3