summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-handle.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/storage/posix/src/posix-handle.c')
-rw-r--r--xlators/storage/posix/src/posix-handle.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c
index d98a9913..0189bb10 100644
--- a/xlators/storage/posix/src/posix-handle.c
+++ b/xlators/storage/posix/src/posix-handle.c
@@ -112,7 +112,7 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize,
char *dir_name = NULL;
char *pgfidstr = NULL;
char *saveptr = NULL;
- size_t len = 0;
+ ssize_t len = 0;
inode_t *inode = NULL;
struct iatt iabuf = {0, };
int ret = -1;
@@ -144,12 +144,19 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize,
}
dir_handle = alloca (handle_size);
- linkname = alloca (512);
+ linkname = alloca (PATH_MAX);
snprintf (dir_handle, handle_size, "%s/%s/%02x/%02x/%s",
priv_base_path, HANDLE_PFX, gfid[0], gfid[1],
uuid_utoa (gfid));
- len = readlink (dir_handle, linkname, 512);
+ len = readlink (dir_handle, linkname, PATH_MAX);
+ if (len < 0) {
+ gf_log (this->name, GF_LOG_ERROR, "could not read the link "
+ "from the gfid handle %s (%s)", dir_handle,
+ strerror (errno));
+ goto out;
+ }
+
linkname[len] = '\0';
pgfidstr = strtok_r (linkname + SLEN("../../00/00/"), "/", &saveptr);