TCMAPKMAXSIZ is used in assignments & comparisons both as bitmask and as integer.
Bug #500589 reported by
eulores
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
tokyocabinet |
New
|
Undecided
|
Unassigned |
Bug Description
In file tcutil.c the constant TCMAPKMAXSIZ is defined as:
#define TCMAPKMAXSIZ 0xfffff
Further down in the file, some excerpts make use of the constant:
a) ... = rec->ksiz & TCMAPKMAXSIZ
b) if(ksiz > TCMAPKMAXSIZ) ...
c) hash &= ~TCMAPKMAXSIZ
If someone changes the #define to a number not consisting of a sequence of binary "1", then statements a) and c) will fail.
I suggest rewriting the #define to something like:
# define TCMAPKMAXSIZ ((1 << 20) - 1)
Otherwise, rewriting statements a) and c) by using for example the ternary operator (?:).
To post a comment you must log in.