From: Maria Matejka Date: Thu, 13 Feb 2025 11:12:20 +0000 (+0100) Subject: Taming static checker: Do not request bits on negative positions in prefixes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d7682d2e49dccb659ada682c9eead3e85cf7e576;p=thirdparty%2Fbird.git Taming static checker: Do not request bits on negative positions in prefixes The code is actually called. It's harmless, yet confusing. --- diff --git a/filter/trie.c b/filter/trie.c index 12ba0b82b..4edd6f2ec 100644 --- a/filter/trie.c +++ b/filter/trie.c @@ -641,7 +641,7 @@ trie_match_longest_ip4(const struct f_trie *t, const net_addr_ip4 *net, net_addr if (len > pxlen) goto done; - if (ip4_getbit(n->accept, len - 1)) + if ((len > 0) && ip4_getbit(n->accept, len - 1)) { /* len is always < 32 due to len < n->plen */ ip4_setbit(&found, len); @@ -735,7 +735,7 @@ trie_match_longest_ip6(const struct f_trie *t, const net_addr_ip6 *net, net_addr if (len > pxlen) goto done; - if (ip6_getbit(n->accept, len - 1)) + if ((len > 0) && ip6_getbit(n->accept, len - 1)) { /* len is always < 128 due to len < n->plen */ ip6_setbit(&found, len);