]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Taming static checker: Do not request bits on negative positions in prefixes
authorMaria Matejka <mq@ucw.cz>
Thu, 13 Feb 2025 11:12:20 +0000 (12:12 +0100)
committerMaria Matejka <mq@ucw.cz>
Sun, 23 Feb 2025 19:26:22 +0000 (20:26 +0100)
The code is actually called. It's harmless, yet confusing.

filter/trie.c

index 12ba0b82b10bf4b89c760f8efbe751d12a5bc0dc..4edd6f2ec5d35c66b54b47fda6b48ecb9b6d3dc4 100644 (file)
@@ -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);