From 099fcac6fecef6fc367d8fcae8442195f3f174db Mon Sep 17 00:00:00 2001
From: nik-redhat <nladha@redhat.com>
Date: Fri, 25 Sep 2020 18:19:39 +0530
Subject: [PATCH 596/610] locks: null dereference
Added a null check before executing the strtok_r()
to avoid null dereference in case of strdup() failure.
CID: 1407938
>Updates: #1060
>Change-Id: Iec6e72ae8cb54f6d0a287615c43756325b2026ec
>Signed-off-by: nik-redhat <nladha@redhat.com>
Upstream link: https://review.gluster.org/c/glusterfs/+/25045
BUG: 1997447
Change-Id: I47e6e2402badaf4103607b4164f19142a99a2f71
Signed-off-by: nik-redhat <nladha@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/c/rhs-glusterfs/+/280065
Tested-by: RHGS Build Bot <nigelb@redhat.com>
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
---
xlators/features/locks/src/posix.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c
index d5effef..03c4907 100644
--- a/xlators/features/locks/src/posix.c
+++ b/xlators/features/locks/src/posix.c
@@ -494,6 +494,9 @@ pl_inodelk_xattr_fill_multiple(dict_t *this, char *key, data_t *value,
char *save_ptr = NULL;
tmp_key = gf_strdup(key);
+ if (!tmp_key)
+ return -1;
+
strtok_r(tmp_key, ":", &save_ptr);
if (!*save_ptr) {
gf_msg(THIS->name, GF_LOG_ERROR, 0, EINVAL,
--
1.8.3.1