From: Renato Westphal Date: Wed, 4 Oct 2017 23:13:56 +0000 (-0300) Subject: lib: fix bug in if_cmp_name_func() X-Git-Tag: frr-4.0-dev~212^2~2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=c9cbbb4054b85947f1ddc52f1ae0b3e18794c784;p=matthieu%2Ffrr.git lib: fix bug in if_cmp_name_func() 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 --- diff --git a/lib/if.c b/lib/if.c index 612cc2081e..36fd509bcb 100644 --- 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)