7c2869
From 1c1e872ad43ab0860e05be679632097296eef174 Mon Sep 17 00:00:00 2001
7c2869
From: Kaushal M <kaushal@redhat.com>
7c2869
Date: Tue, 10 Jul 2018 20:56:08 +0530
7c2869
Subject: [PATCH 686/689] glusterd: _is_prefix should handle 0-length paths
7c2869
7c2869
If one of the paths given to _is_prefix is 0-length, then it is not a
7c2869
prefix of the other. Hence, _is_prefix should return false.
7c2869
7c2869
>Change-Id: I54aa577a64a58940ec91872d0d74dc19cff9106d
7c2869
>fixes: bz#1599783
7c2869
>Signed-off-by: Kaushal M <kaushal@redhat.com>
7c2869
7c2869
upstream patch: https://review.gluster.org/#/c/20490/
7c2869
7c2869
Change-Id: I54aa577a64a58940ec91872d0d74dc19cff9106d
7c2869
BUG: 1599803
7c2869
Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
7c2869
Reviewed-on: https://code.engineering.redhat.com/gerrit/143746
7c2869
Tested-by: RHGS Build Bot <nigelb@redhat.com>
7c2869
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
7c2869
---
7c2869
 xlators/mgmt/glusterd/src/glusterd-utils.c | 9 +++++++++
7c2869
 1 file changed, 9 insertions(+)
7c2869
7c2869
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
7c2869
index bbf6f7d..8e1048c 100644
7c2869
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
7c2869
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
7c2869
@@ -1269,6 +1269,15 @@ _is_prefix (char *str1, char *str2)
7c2869
         len1 = strlen (str1);
7c2869
         len2 = strlen (str2);
7c2869
         small_len = min (len1, len2);
7c2869
+
7c2869
+        /*
7c2869
+         * If either one (not both) of the strings are 0-length, they are not
7c2869
+         * prefixes of each other.
7c2869
+         */
7c2869
+        if ((small_len == 0) && (len1 != len2)) {
7c2869
+                return _gf_false;
7c2869
+        }
7c2869
+
7c2869
         for (i = 0; i < small_len; i++) {
7c2869
                 if (str1[i] != str2[i]) {
7c2869
                         prefix = _gf_false;
7c2869
-- 
7c2869
1.8.3.1
7c2869