|
Description
|
#define PS_HASH(msg, hash, len) \
{ \
uint_t key = 0x12345678; /* arbitrary value */ \
int i; \
\
(hash) = MOD2((key + (len)), NFSID_CACHE_ANCHORS); \
\
for (i = 0; i < ((len) - 1); i++) { \
(hash) = MOD2(((hash) + (msg)[i]), NFSID_CACHE_ANCHORS); \
(hash) = pkp_tab[(hash)]; \
} \
}
That should be:
for (i = 0; i < (len); i++) { \
As it is, the code is skipping the last character in the string. Here is some
test output from some code:
[th199096@new-anthrax ~/tests]> ./a.out
/sharem/dir1 hashes to 103
/sharem/dir2 hashes to 103
/sahrem/dir2
/sahrem/dir2 hashes to 45
/sharem/dir3
/sharem/dir3 hashes to 103
^C
[th199096@new-anthrax ~/tests]> ./a.out
/sharem/dir1 hashes to 103
/sharem/dir2 hashes to 103
/sharem/dira
/sharem/dira hashes to 103
.
With the fix:
[th199096@new-anthrax ~/tests]> ./a.out
/sharem/dir1 hashes to 241
/sharem/dir2 hashes to 236
.
Test code is here:
[th199096@new-anthrax ~/tests]> pwd
/home/th199096/tests
[th199096@new-anthrax ~/tests]> ls -la sharetab.c
-rw-r--r-- 1 th199096 staff 2086 Dec 22 11:55 sharetab.c
|