summaryrefslogtreecommitdiffstats
path: root/xlators/debug/error-gen
diff options
context:
space:
mode:
authorVijay Bellur <vbellur@redhat.com>2018-08-14 15:36:00 -0700
committerAmar Tumballi <amarts@redhat.com>2018-08-18 05:50:00 +0000
commit045d70a5450daa85aa5564b6e9f93065c342ab12 (patch)
tree66e529deac8ce834f70b7bec8bffec5e015dec8b /xlators/debug/error-gen
parent41e768f65bf63c9da22f7125e1eeb77d9c775352 (diff)
debug/error-gen: Fix null deref and out of bounds read issues
Addresses CID: 1124492, 1124700, 1124701 Change-Id: If9916df1b0a4e67ad74fe0f6ea6f2544598ddacb updates: bz#789278 Signed-off-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/debug/error-gen')
-rw-r--r--xlators/debug/error-gen/src/error-gen.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/xlators/debug/error-gen/src/error-gen.c b/xlators/debug/error-gen/src/error-gen.c
index f5180e5..7ad2a0b 100644
--- a/xlators/debug/error-gen/src/error-gen.c
+++ b/xlators/debug/error-gen/src/error-gen.c
@@ -193,8 +193,11 @@ int
generate_rand_no (int op_no)
{
int rand_no = 0;
+ int error_no_list_size = 0;
- if (op_no < GF_FOP_MAXVALUE)
+ error_no_list_size = sizeof(error_no_list)/sizeof(error_no_list[0]);
+
+ if (op_no < error_no_list_size)
/* coverity[DC.WEAK_CRYPTO] */
rand_no = rand () % error_no_list[op_no].error_no_count;
return rand_no;
@@ -266,6 +269,7 @@ error_gen (xlator_t *this, int op_no)
int rand_no = 0;
int ret = 0;
gf_boolean_t should_err = _gf_false;
+ int error_no_list_size = 0;
egp = this->private;
@@ -304,12 +308,13 @@ error_gen (xlator_t *this, int op_no)
}
}
+ error_no_list_size = sizeof(error_no_list)/sizeof(error_no_list[0]);
if (should_err) {
if (error_no_int)
ret = error_no_int;
else {
rand_no = generate_rand_no (op_no);
- if (op_no >= GF_FOP_MAXVALUE)
+ if (op_no >= error_no_list_size)
op_no = 0;
if (rand_no >= error_no_list[op_no].error_no_count)
rand_no = 0;