From: Richard Weinberger Date: Thu, 18 Oct 2018 14:36:41 +0000 (+0200) Subject: mkfs.ubifs: Make r5 hash binary string aware X-Git-Tag: v2.1.0~45 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2fd902f11823433ba9332da3106253b674563542;p=mtd-utils.git 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 --- 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;