e7a346
From 2489f91d395740b42f21322744ab64427e94a683 Mon Sep 17 00:00:00 2001
e7a346
From: Jiffin Tony Thottan <jthottan@redhat.com>
e7a346
Date: Tue, 31 Jul 2018 14:52:51 +0530
e7a346
Subject: [PATCH 346/351] gfapi : Handle the path == "" glfs_resolve_at
e7a346
e7a346
Currently there is no check for path = "" in glfs_resolve_at.
e7a346
So if application sends an empty path, then the function resolves
e7a346
into the parent inode which is incorrect. Plus modified possible
e7a346
of "path" with "origpath" in the same function.
e7a346
e7a346
Upstream reference
e7a346
>Change-Id: Ie5ff9ce4b771607b7dbb3fe00704fe670421792a
e7a346
>fixes: bz#1610236
e7a346
>Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
e7a346
>link : https://review.gluster.org/#/c/glusterfs/+/20594/
e7a346
e7a346
Change-Id: Ie5ff9ce4b771607b7dbb3fe00704fe670421792a
e7a346
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
e7a346
Reviewed-on: https://code.engineering.redhat.com/gerrit/146938
e7a346
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
e7a346
---
e7a346
 api/src/glfs-resolve.c | 17 ++++++++++-------
e7a346
 1 file changed, 10 insertions(+), 7 deletions(-)
e7a346
e7a346
diff --git a/api/src/glfs-resolve.c b/api/src/glfs-resolve.c
e7a346
index 76835cb..95fe67a 100644
e7a346
--- a/api/src/glfs-resolve.c
e7a346
+++ b/api/src/glfs-resolve.c
e7a346
@@ -472,14 +472,13 @@ priv_glfs_resolve_at (struct glfs *fs, xlator_t *subvol, inode_t *at,
e7a346
 	DECLARE_OLD_THIS;
e7a346
 	__GLFS_ENTRY_VALIDATE_FS(fs, invalid_fs);
e7a346
 
e7a346
-	path = gf_strdup (origpath);
e7a346
-	if (!path) {
e7a346
-		errno = ENOMEM;
e7a346
-		return -1;
e7a346
-	}
e7a346
+        if (origpath[0] == '\0') {
e7a346
+                errno = EINVAL;
e7a346
+                goto invalid_fs;
e7a346
+        }
e7a346
 
e7a346
 	parent = NULL;
e7a346
-	if (at && path[0] != '/') {
e7a346
+	if (at && origpath[0] != '/') {
e7a346
 		/* A relative resolution of a path which starts with '/'
e7a346
 		   is equal to an absolute path resolution.
e7a346
 		*/
e7a346
@@ -487,10 +486,14 @@ priv_glfs_resolve_at (struct glfs *fs, xlator_t *subvol, inode_t *at,
e7a346
 	} else {
e7a346
 		inode = inode_ref (subvol->itable->root);
e7a346
 
e7a346
-		if (strcmp (path, "/") == 0)
e7a346
+		if (strcmp (origpath, "/") == 0)
e7a346
                         glfs_resolve_root (fs, subvol, inode, &ciatt);
e7a346
 	}
e7a346
 
e7a346
+        path = gf_strdup (origpath);
e7a346
+	if (!path)
e7a346
+		goto invalid_fs;
e7a346
+
e7a346
 	for (component = strtok_r (path, "/", &saveptr);
e7a346
 	     component; component = next_component) {
e7a346
 
e7a346
-- 
e7a346
1.8.3.1
e7a346