diff options
author | Raghavendra G <rgowdapp@redhat.com> | 2013-08-20 16:47:32 +0530 |
---|---|---|
committer | Raghavendra G <rgowdapp@redhat.com> | 2013-09-03 10:28:04 +0530 |
commit | d3af16845d2a529a95ef25f4a712c208945c5d7f (patch) | |
tree | 2704b1605ffa086696a6b8237760109b062043d2 | |
parent | 496623012fc0c300e26b03908e1f47d1347ce664 (diff) |
storage/posix: fix issues with constructing correct path as part of
handling GET_ANCESTRY_PATH key.
Change-Id: Ibb1cd1b4d9cd2d6f85b642c2dd157f68d18b8d41
BUG: 969461
Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
-rw-r--r-- | xlators/storage/posix/src/posix-handle.c | 18 | ||||
-rw-r--r-- | xlators/storage/posix/src/posix.c | 1 |
2 files changed, 11 insertions, 8 deletions
diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c index 34c66d63..d98a9913 100644 --- a/xlators/storage/posix/src/posix-handle.c +++ b/xlators/storage/posix/src/posix-handle.c @@ -61,15 +61,13 @@ posix_make_ancestral_node (const char *priv_base_path, char *path, int pathsize, loc_t loc = {0, }; int ret = -1; - if (type & POSIX_ANCESTRY_PATH) { - len = strlen (path) + strlen (dir_name) + 1; - if (len > pathsize) { - goto out; - } - - strcat (path, dir_name); + len = strlen (path) + strlen (dir_name) + 1; + if (len > pathsize) { + goto out; } + strcat (path, dir_name); + if (type & POSIX_ANCESTRY_DENTRY) { entry = gf_dirent_for_name (dir_name); if (!entry) { @@ -86,7 +84,7 @@ posix_make_ancestral_node (const char *priv_base_path, char *path, int pathsize, list_add_tail (&entry->list, &head->list); strcpy (real_path, priv_base_path); strcat (real_path, "/"); - strcat (real_path, dir_name); + strcat (real_path, path); loc.inode = inode_ref (inode); uuid_copy (loc.gfid, inode->gfid); @@ -120,6 +118,10 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize, int ret = -1; uuid_t tmp_gfid = {0, }; + if (!path || !parent || !priv_base_path || uuid_is_null (gfid)) { + goto out; + } + if (__is_root_gfid (gfid)) { if (parent) { if (*parent) { diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index a4fb9881..903cae9d 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -2999,6 +2999,7 @@ posix_get_ancestry_non_directory (xlator_t *this, char *real_path, loc_t *loc, char real_path[PATH_MAX + 1] = {0, }; strcpy (real_path, dirpath); + strcat (real_path, "/"); strcat (real_path, entry->d_name); gf_entry = gf_dirent_for_name (entry->d_name); |