Skip to content

Commit

Permalink
Merge pull request FRRouting#14443 from opensourcerouting/coverity-re…
Browse files Browse the repository at this point in the history
…dux-20230919

lib: constrain hash table "tabshift" both ways
  • Loading branch information
donaldsharp committed Sep 20, 2023
2 parents 2341a65 + e7737c8 commit 7a80a23
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/typesafe.h
Original file line number Diff line number Diff line change
Expand Up @@ -795,13 +795,16 @@ struct thash_head {
uint8_t minshift, maxshift;
};

#define _HASH_SIZE(tabshift) \
((1U << (tabshift)) >> 1)
#define _HASH_SIZE(tabshift) \
({ \
assume((tabshift) <= 31); \
(1U << (tabshift)) >> 1; \
})
#define HASH_SIZE(head) \
_HASH_SIZE((head).tabshift)
#define _HASH_KEY(tabshift, val) \
({ \
assume((tabshift) >= 2 && (tabshift) <= 33); \
assume((tabshift) >= 2 && (tabshift) <= 31); \
(val) >> (33 - (tabshift)); \
})
#define HASH_KEY(head, val) \
Expand Down

0 comments on commit 7a80a23

Please sign in to comment.