Download raw body.
bgpd: Use 1ULL in shift operations on uint64_t values
When shifting 1 << level into a 64bit value use 1ULL so the shift happens
on a 64bit value. I doubt we'll see tables with more than 31 levels but
lets be correct.
Fix for CID 492339, CID 492340, CID 492357, CID 492363
--
:wq Claudio
Index: chash.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/chash.c,v
diff -u -p -r1.3 chash.c
--- chash.c 3 Nov 2025 13:48:19 -0000 1.3
+++ chash.c 4 Nov 2025 12:48:14 -0000
@@ -517,8 +517,8 @@ ch_table_resize(struct ch_table *t)
{
struct ch_group **tables;
struct ch_meta **metas;
- uint64_t oldsize = 1 << t->ch_level;
- uint64_t newsize = 1 << (t->ch_level + 1);
+ uint64_t oldsize = 1ULL << t->ch_level;
+ uint64_t newsize = 1ULL << (t->ch_level + 1);
int64_t idx;
if (t->ch_level + 1 >= CH_H1_BITS) {
@@ -566,7 +566,7 @@ ch_table_fill(struct ch_table *t, uint64
uint64_t cnt, i;
idx <<= (t->ch_level - meta->cs_local_level);
- cnt = 1 << (t->ch_level - meta->cs_local_level);
+ cnt = 1ULL << (t->ch_level - meta->cs_local_level);
for (i = 0; i < cnt; i++) {
t->ch_tables[idx + i] = table;
@@ -722,7 +722,7 @@ _ch_init(const struct ch_type *type, str
void
_ch_destroy(const struct ch_type *type, struct ch_table *t)
{
- uint64_t idx, max = 1 << t->ch_level;
+ uint64_t idx, max = 1ULL << t->ch_level;
struct ch_group *table = NULL;
for (idx = 0; idx < max; idx++) {
@@ -859,7 +859,7 @@ _ch_next(const struct ch_type *type, str
if (t->ch_tables == NULL)
return NULL;
- max = 1 << t->ch_level;
+ max = 1ULL << t->ch_level;
idx = it->ci_ext_idx;
if (idx >= max)
return NULL;
bgpd: Use 1ULL in shift operations on uint64_t values