diff options
author | Yaniv Kaul <ykaul@redhat.com> | 2019-10-31 18:13:16 +0200 |
---|---|---|
committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2019-11-04 07:01:02 +0000 |
commit | 7a1c912a6b145cbf3b22884a7a6b2dfe16fb5de0 (patch) | |
tree | 43f76a84e5615f473c78cac877c05ae8cb8da60f /xlators/storage | |
parent | 13cb14811cdea477780e58ba35493479c7a04a25 (diff) |
posix-entry-ops.c: pass correct key length in posix_skip_non_linkto_unlink()
As was found out in a different patch, passing a pointer
to a constant string still calculates the size of the pointer
and not the string. This is not catastrophic as the dictionary
is matching not just hashes but key names, but is certainly what
was intended to be done.
Instead, pass explicitly the key lenth.
I've looked for additional cases for such an issue and did not
find them, luckily.
Change-Id: I644a07a77dd541e9cf4886811ab54897e0c9d483
updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
Diffstat (limited to 'xlators/storage')
-rw-r--r-- | xlators/storage/posix/src/posix-entry-ops.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/xlators/storage/posix/src/posix-entry-ops.c b/xlators/storage/posix/src/posix-entry-ops.c index 9b9e624de3f..ef2ef0a8b3b 100644 --- a/xlators/storage/posix/src/posix-entry-ops.c +++ b/xlators/storage/posix/src/posix-entry-ops.c @@ -1047,8 +1047,8 @@ err: static gf_boolean_t posix_skip_non_linkto_unlink(dict_t *xdata, loc_t *loc, char *key, - const char *linkto_xattr, struct iatt *stbuf, - const char *real_path) + const int keylen, const char *linkto_xattr, + struct iatt *stbuf, const char *real_path) { gf_boolean_t skip_unlink = _gf_false; gf_boolean_t is_dht_linkto_file = _gf_false; @@ -1056,7 +1056,7 @@ posix_skip_non_linkto_unlink(dict_t *xdata, loc_t *loc, char *key, ssize_t xattr_size = -1; int op_ret = -1; - op_ret = dict_get_int32_sizen(xdata, key, &unlink_if_linkto); + op_ret = dict_get_int32n(xdata, key, keylen, &unlink_if_linkto); if (!op_ret && unlink_if_linkto) { is_dht_linkto_file = IS_DHT_LINKFILE_MODE(stbuf); @@ -1183,9 +1183,11 @@ posix_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, * we don't need to call second function, skip unlink. */ skip_unlink = posix_skip_non_linkto_unlink( - xdata, loc, DHT_SKIP_NON_LINKTO_UNLINK, DHT_LINKTO, &stbuf, real_path); + xdata, loc, DHT_SKIP_NON_LINKTO_UNLINK, + SLEN(DHT_SKIP_NON_LINKTO_UNLINK), DHT_LINKTO, &stbuf, real_path); skip_unlink = skip_unlink || posix_skip_non_linkto_unlink( xdata, loc, TIER_SKIP_NON_LINKTO_UNLINK, + SLEN(TIER_SKIP_NON_LINKTO_UNLINK), TIER_LINKTO, &stbuf, real_path); if (skip_unlink) { op_ret = -1; |