diff options
author | Pranith Kumar K <pkarampu@redhat.com> | 2018-06-26 15:58:02 +0530 |
---|---|---|
committer | jiffin tony Thottan <jthottan@redhat.com> | 2018-07-04 04:03:10 +0000 |
commit | b11866a596bcd16a9fc37317929471e9a4b1d299 (patch) | |
tree | 776bee93327022256a7ad9254a8ba14f139863ef /xlators/storage | |
parent | 335f6e8be4a556095c0ac1aecbc43b8e85741fdb (diff) |
storage/posix: Fix posix_symlinks_match()
1) snprintf into linkname_expected should happen with PATH_MAX
2) comparison should happen with linkname_actual with complete
string linkname_expected
fixes bz#1595528
Change-Id: Ic3b3c362dc6c69c046b9a13e031989be47ecff14
BUG: 1595528
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Diffstat (limited to 'xlators/storage')
-rw-r--r-- | xlators/storage/posix/src/posix.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 69674504b19..723b181ccfa 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -124,17 +124,27 @@ posix_symlinks_match (xlator_t *this, loc_t *loc, uuid_t gfid) handle_size = POSIX_GFID_HANDLE_SIZE(priv->base_path_length); dir_handle = alloca0 (handle_size); - snprintf (linkname_expected, handle_size, "../../%02x/%02x/%s/%s", + snprintf (linkname_expected, PATH_MAX, "../../%02x/%02x/%s/%s", loc->pargfid[0], loc->pargfid[1], uuid_utoa (loc->pargfid), loc->name); MAKE_HANDLE_GFID_PATH (dir_handle, this, gfid, NULL); len = sys_readlink (dir_handle, linkname_actual, PATH_MAX); - if (len < 0) + if (len < 0 || len == PATH_MAX) { + if (len == PATH_MAX) { + errno = EINVAL; + } + + if (errno != ENOENT) { + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_LSTAT_FAILED, "readlink[%s] failed", + dir_handle); + } goto out; + } linkname_actual[len] = '\0'; - if (!strncmp (linkname_actual, linkname_expected, handle_size)) + if (!strcmp (linkname_actual, linkname_expected)) ret = _gf_true; out: |