OpenSolaris

Printable Version Enter a New Search
Bug ID 6507643
Synopsis Hash function in nfs id mapper ignores the last character in the string
State 10-Fix Delivered (Fix available in build)
Category:Subcategory kernel:nfsv4
Keywords
Responsible Engineer Thomas Haynes
Reported Against
Duplicate Of
Introduced In solaris_10
Commit to Fix snv_59
Fixed In snv_59
Release Fixed solaris_nevada(snv_59)
Related Bugs
Submit Date 22-December-2006
Last Update Date 2-March-2007
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
Work Around
N/A
Comments
N/A