From 7dc26f19055f66efc1b059d39d46008c3f0dd20d Mon Sep 17 00:00:00 2001 From: Louis Burda Date: Mon, 10 May 2021 18:08:29 +0200 Subject: fixed hash parsing from info file and only query non-hidden dirs in standard user mode --- service/src/util.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'service/src/util.c') diff --git a/service/src/util.c b/service/src/util.c index d947f3d..9f91f6b 100644 --- a/service/src/util.c +++ b/service/src/util.c @@ -46,7 +46,7 @@ const char* mhash(const char *filename, int len) { static const char *hexalph = "0123456789ABCDEF"; - static char buf[MHASHLEN + 1]; + static char buf[2 * MHASHLEN + 1]; int i, k; if (len == -1) len = strlen(filename); @@ -55,8 +55,8 @@ mhash(const char *filename, int len) unsigned char v = 0; for (k = i; k < len; k += MHASHLEN) v ^= filename[k]; - buf[i*2+1] = hexalph[(v >> 4) & 0x0f]; - buf[i*2+0] = hexalph[(v >> 0) & 0x0f]; + buf[i*2+0] = hexalph[(v >> 4) & 0x0f]; + buf[i*2+1] = hexalph[(v >> 0) & 0x0f]; } if (i == 0) { @@ -81,8 +81,9 @@ freadstr(FILE *f, char **dst) for (len = 0; (c = fgetc(f)) != EOF && c; len++); fseek(f, start, SEEK_SET); - *dst = calloc(len + 1, 1); + *dst = checkp(calloc(1, len + 1)); fread(*dst, len, 1, f); + fgetc(f); } void -- cgit v1.2.3-71-gd317