Skip to content

Commit 11b7912

Browse files
authored
fuzz: more initialized memory for MSAN (#434)
1 parent 7301399 commit 11b7912

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

pkcs11/fuzz/fuzz_get_attribute_value.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,15 @@ void derive_ecdh_session_keys(uint8_t derived_key_count,
139139
CK_OBJECT_HANDLE ecdh = {0};
140140

141141
CK_ECDH1_DERIVE_PARAMS params = {0};
142-
memset(&params, 0, sizeof(params));
143142
params.kdf = CKD_NULL;
144143
params.pSharedData = NULL;
145144
params.ulSharedDataLen = 0;
146145
// TODO populate pPublicData and ulPublicDataLen from fuzzer generated data?
147146
params.pPublicData = new uint8_t[50];
147+
memset(params.pPublicData, 0, 50);
148148
params.ulPublicDataLen = 50;
149149

150150
CK_MECHANISM mechanism = {0};
151-
memset(&mechanism, 0, sizeof(mechanism));
152151
mechanism.mechanism = CKM_ECDH1_DERIVE;
153152
mechanism.pParameter = (void *) &params;
154153
mechanism.ulParameterLen = sizeof(params);
@@ -185,8 +184,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
185184

186185
FuzzedDataProvider *fdp = new FuzzedDataProvider(data, size);
187186

188-
test_case_t test_case;
189-
memset(&test_case, 0, sizeof(test_case_t));
187+
test_case_t test_case = {0};
190188
test_case.attribute_count = fdp->ConsumeIntegral<CK_ULONG>();
191189
test_case.obj_handle = fdp->ConsumeIntegral<CK_OBJECT_HANDLE>();
192190
test_case.derived_ecdh_key_count = fdp->ConsumeIntegral<uint8_t>();
@@ -198,8 +196,8 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
198196
test_case.attribute_count = 10;
199197
}
200198

201-
CK_ATTRIBUTE_PTR attribute_array;
202-
CK_ATTRIBUTE_PTR ecdh_attribute_array;
199+
CK_ATTRIBUTE_PTR attribute_array = NULL;
200+
CK_ATTRIBUTE_PTR ecdh_attribute_array = NULL;
203201
populate_attribute_template(&attribute_array, test_case.attribute_count, fdp);
204202
populate_derived_ecdh_key_template(&ecdh_attribute_array, fdp);
205203

0 commit comments

Comments
 (0)