diff options
| author | Jiffin Tony Thottan <jthottan@redhat.com> | 2018-07-31 14:52:51 +0530 | 
|---|---|---|
| committer | jiffin tony Thottan <jthottan@redhat.com> | 2018-08-17 05:34:53 +0000 | 
| commit | f727b47d988066f9c8e123059836fabf2e28db09 (patch) | |
| tree | fe037ae38a9fbff2efb7f0f073ce8185ad1b4929 | |
| parent | dfbc7eaa8258721670a66fc49df7774cb248ff4f (diff) | |
gfapi : Handle the path == "" glfs_resolve_at
Currently there is no check for path = "" in glfs_resolve_at.
So if application sends an empty path, then the function resolves
into the parent inode which is incorrect. Plus modified possible
of "path" with "origpath" in the same function.
>Change-Id: Ie5ff9ce4b771607b7dbb3fe00704fe670421792a
>fixes: bz#1610236
>Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
>(cherry picked from commit febee007bb1a99d65300630c2a98cbb642b1c8dc)
Change-Id: Ie5ff9ce4b771607b7dbb3fe00704fe670421792a
fixes: bz#1618348
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
| -rw-r--r-- | api/src/glfs-resolve.c | 17 | 
1 files changed, 10 insertions, 7 deletions
diff --git a/api/src/glfs-resolve.c b/api/src/glfs-resolve.c index 76835cbaebd..95fe67afb48 100644 --- a/api/src/glfs-resolve.c +++ b/api/src/glfs-resolve.c @@ -472,14 +472,13 @@ priv_glfs_resolve_at (struct glfs *fs, xlator_t *subvol, inode_t *at,  	DECLARE_OLD_THIS;  	__GLFS_ENTRY_VALIDATE_FS(fs, invalid_fs); -	path = gf_strdup (origpath); -	if (!path) { -		errno = ENOMEM; -		return -1; -	} +        if (origpath[0] == '\0') { +                errno = EINVAL; +                goto invalid_fs; +        }  	parent = NULL; -	if (at && path[0] != '/') { +	if (at && origpath[0] != '/') {  		/* A relative resolution of a path which starts with '/'  		   is equal to an absolute path resolution.  		*/ @@ -487,10 +486,14 @@ priv_glfs_resolve_at (struct glfs *fs, xlator_t *subvol, inode_t *at,  	} else {  		inode = inode_ref (subvol->itable->root); -		if (strcmp (path, "/") == 0) +		if (strcmp (origpath, "/") == 0)                          glfs_resolve_root (fs, subvol, inode, &ciatt);  	} +        path = gf_strdup (origpath); +	if (!path) +		goto invalid_fs; +  	for (component = strtok_r (path, "/", &saveptr);  	     component; component = next_component) {  | 
