summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-store.c
diff options
context:
space:
mode:
authorSunny Kumar <sunkumar@redhat.com>2018-09-04 14:13:18 +0530
committerAtin Mukherjee <amukherj@redhat.com>2018-09-05 02:20:29 +0000
commit4d198e33ba2ff5b550e8095af3c8d0b76c18bc2f (patch)
tree21bb06a776f1335603d95e8fc43b98e21f614217 /xlators/mgmt/glusterd/src/glusterd-store.c
parent8612a1ca192333c2b760455661647d83bed2fd92 (diff)
glusterd : fix some coverity issues in glusterd-store.c
This patch fixes CID 1382346, 1274190 and 1382403. Change-Id: I1968e686587719e74bd70fa1542c20bccc04a7f9 updates: bz#789278 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-store.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index 6dd9764875b..1f43b7fa82d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -2566,7 +2566,16 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo)
} else if (!strncmp (key, GLUSTERD_STORE_KEY_BRICK_DECOMMISSIONED,
strlen (GLUSTERD_STORE_KEY_BRICK_DECOMMISSIONED))) {
- gf_string2int (value, &brickinfo->decommissioned);
+ ret = gf_string2int
+ (value, &brickinfo->decommissioned);
+ if (ret == -1) {
+ gf_msg (this->name, GF_LOG_ERROR,
+ EINVAL,
+ GD_MSG_INCOMPATIBLE_VALUE,
+ "Failed to convert "
+ "string to integer");
+ }
+
} else if (!strncmp (key, GLUSTERD_STORE_KEY_BRICK_DEVICE_PATH,
strlen (GLUSTERD_STORE_KEY_BRICK_DEVICE_PATH))) {
strncpy (brickinfo->device_path, value,
@@ -2577,7 +2586,16 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo)
sizeof (brickinfo->mount_dir));
} else if (!strncmp (key, GLUSTERD_STORE_KEY_BRICK_SNAP_STATUS,
strlen (GLUSTERD_STORE_KEY_BRICK_SNAP_STATUS))) {
- gf_string2int (value, &brickinfo->snap_status);
+ ret = gf_string2int (value,
+ &brickinfo->snap_status);
+ if (ret == -1) {
+ gf_msg (this->name, GF_LOG_ERROR,
+ EINVAL,
+ GD_MSG_INCOMPATIBLE_VALUE,
+ "Failed to convert "
+ "string to integer");
+ }
+
} else if (!strncmp (key, GLUSTERD_STORE_KEY_BRICK_FSTYPE,
strlen (GLUSTERD_STORE_KEY_BRICK_FSTYPE))) {
strncpy (brickinfo->fstype, value,
@@ -2597,7 +2615,15 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo)
} else if (!strncmp (key,
GLUSTERD_STORE_KEY_BRICK_FSID,
strlen (GLUSTERD_STORE_KEY_BRICK_FSID))) {
- gf_string2uint64 (value, &brickinfo->statfs_fsid);
+ ret = gf_string2uint64
+ (value, &brickinfo->statfs_fsid);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_INVALID_ENTRY, "%s "
+ "is not a valid uint64_t value",
+ value);
+ }
+
} else if (!strcmp(key,
GLUSTERD_STORE_KEY_BRICK_UUID)) {
gf_uuid_parse (value, brickinfo->uuid);
@@ -4512,6 +4538,12 @@ glusterd_store_retrieve_peers (xlator_t *this)
key,
strlen (GLUSTERD_STORE_KEY_PEER_HOSTNAME))) {
ret = gd_add_address_to_peer (peerinfo, value);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_ADD_ADDRESS_TO_PEER_FAIL,
+ "Could not add address to peer"
+ );
+ }
} else {
gf_msg (this->name, GF_LOG_ERROR, 0,
GD_MSG_UNKNOWN_KEY, "Unknown key: %s",