From 4a1d4e86fcf221cdbab551198255b0fcfc91295a Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 23 Jan 2013 15:12:10 -0800 Subject: [PATCH] bridge: Fix bug in equal_pathnames(). Reported-by: Pavithra Ramesh Acked-by: Pavithra Ramesh Signed-off-by: Ben Pfaff --- vswitchd/bridge.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 82c3bffc8..dd3099f84 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -2740,8 +2740,12 @@ static bool equal_pathnames(const char *a, const char *b, size_t b_stoplen) { const char *b_start = b; - while (b - b_start < b_stoplen && *a == *b) { - if (*a == '/') { + for (;;) { + if (b - b_start >= b_stoplen) { + return true; + } else if (*a != *b) { + return false; + } else if (*a == '/') { a += strspn(a, "/"); b += strspn(b, "/"); } else if (*a == '\0') { @@ -2751,7 +2755,6 @@ equal_pathnames(const char *a, const char *b, size_t b_stoplen) b++; } } - return false; } static void -- 2.43.0