summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-entry-ops.c
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2018-06-26 15:58:02 +0530
committerShyamsundar Ranganathan <srangana@redhat.com>2018-07-02 17:14:07 +0000
commit0894e1d3af83228fb02310e61c1dafea2dc56ef9 (patch)
treec2571e5b61e9f81cc7ca0ae905dcb246989f57bb /xlators/storage/posix/src/posix-entry-ops.c
parent8f6e437073ee20d8f1ec8efc57b9aac86d09269d (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#1595524 Change-Id: Ic3b3c362dc6c69c046b9a13e031989be47ecff14 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> (cherry picked from commit 3099d3e6ba81d3e1abf37385b13aabf5837b9c5e)
Diffstat (limited to 'xlators/storage/posix/src/posix-entry-ops.c')
-rw-r--r--xlators/storage/posix/src/posix-entry-ops.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/xlators/storage/posix/src/posix-entry-ops.c b/xlators/storage/posix/src/posix-entry-ops.c
index 519b6f3f040..b4bbafae91a 100644
--- a/xlators/storage/posix/src/posix-entry-ops.c
+++ b/xlators/storage/posix/src/posix-entry-ops.c
@@ -104,17 +104,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: