]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: fix bug in if_cmp_name_func()
authorRenato Westphal <renato@opensourcerouting.org>
Wed, 4 Oct 2017 23:13:56 +0000 (20:13 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Tue, 10 Oct 2017 12:05:02 +0000 (09:05 -0300)
If the p1 and p2 arguments pointed to identical strings ending with
a non-numeric character (e.g. "lo"), this function would return -1
instead of 0 as one would expect. This inconsistency didn't matter
for sorted linked-lists but for red-black trees it's a major source
of problems.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
lib/if.c

index 612cc2081e23432cf0b4d2426fdd5d617db287c4..36fd509bcba65c9d1a01951b811abd018d770155 100644 (file)
--- a/lib/if.c
+++ b/lib/if.c
@@ -91,6 +91,8 @@ int if_cmp_name_func(char *p1, char *p2)
                p1 += l1;
                p2 += l1;
 
+               if (!*p1 && !*p2)
+                       return 0;
                if (!*p1)
                        return -1;
                if (!*p2)