summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVarun Shastry <vshastry@redhat.com>2013-08-27 18:04:07 +0530
committerGerrit Code Review <review@dev.gluster.org>2013-09-24 23:30:15 -0700
commit74be3343303ff9014aca780b4e4ed604ffde9fa3 (patch)
treefdad3ded03bf14e98c595bbabc395b97ffd1d0d5
parentc1958d703af67ae7154c8ff8ff348c39853e6b6f (diff)
storage/posix: check the return value of readlink before building the ancestry
* Also collect the return value of readlink in a signed entity intead of an unsigned entity, in which case failures cannot be detected. Change-Id: Ia73b97c15a1e9be518193fd57598e7c6eadca05c BUG: 969461 Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com> Signed-off-by: Varun Shastry <vshastry@redhat.com>
-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);