ref: 969f1e1ceb07a5ce0b45802fc6513ba2d67f1c0b
parent: 693b886abbc71ece150ca9d462488672d2ebea98
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Fri Feb 19 14:13:08 EST 2016
devfs-win32: use sha1() for pathhash
--- a/kern/devfs-win32.c
+++ b/kern/devfs-win32.c
@@ -9,6 +9,8 @@
#include "fns.h"
#include "error.h"
+#include <libsec.h> /* for sha1 in pathhash() */
+
typedef struct DIR DIR;
typedef struct Ufsinfo Ufsinfo;
@@ -65,11 +67,11 @@
static uvlong
pathhash(TCHAR *p)
{
- uvlong h;
- h = 0LL;
- for(; *p; p++)
- h += *p * 13;
- return h;
+ uchar digest[SHA1dlen];
+ int n;
+ for(n=0; p[n] != 0; n++);
+ sha1((uchar*)p, n*sizeof(TCHAR), digest, nil);
+ return *(uvlong*)digest;
}
static ulong