summaryrefslogtreecommitdiffstats
path: root/xlators/storage
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2018-06-26 15:58:02 +0530
committerPranith Kumar K <pkarampu@redhat.com>2018-06-26 21:31:26 +0530
commit3099d3e6ba81d3e1abf37385b13aabf5837b9c5e (patch)
tree9bf142b98e410cb176c28c8cdcc9f1ed4910d875 /xlators/storage
parentd6cd792af722c795df48eae68806add4c33e18f5 (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#1595190 Change-Id: Ic3b3c362dc6c69c046b9a13e031989be47ecff14 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Diffstat (limited to 'xlators/storage')
-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 bf572eb53aa..4241b574bc4 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: