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