This is a rare bug which only appears if the tree has not been 100%
optimised which might happen because it would not be worth the effort to
remove all dead ends all of the time.
Therefore, we could be reaching a node which is not an actual leaf but
still not find our network. In that case, we will have to go backwards
slightly to check if there has been a less specific match (but a match
nonetheless).
This was broken in commit
9e72b8a0c56403ca7d23c6a767d66038e0d63c14 when
the return code for no match was changed to zero.
Fixes: #13861 - libloc-0.9.18 fails to find some ASN info
Reported-by: Adolf Belka <adolf.belka@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
// Move on to the next node
r = __loc_database_lookup(db, address, network, network_address, node_index, level + 1);
-
- // End here if a result was found
- if (r == 0)
- return r;
-
- // Raise any errors
- else if (r < 0)
+ if (r < 0)
return r;
DEBUG(db->ctx, "No match found below level %u\n", level);
}
// If this node has a leaf, we will check if it matches
- if (__loc_database_node_is_leaf(node_v1)) {
+ if (!*network && __loc_database_node_is_leaf(node_v1)) {
r = __loc_database_lookup_handle_leaf(db, address, network, network_address, level, node_v1);
if (r < 0)
return r;