Skip to content

Commit

Permalink
template_kem.c: Check outlen before dereferencing it
Browse files Browse the repository at this point in the history
Fixes Coverity 1633353, 1633356, 1633357
  • Loading branch information
t8m committed Jan 22, 2025
1 parent 5b589fc commit 5671a8d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions providers/implementations/kem/template_kem.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ static int template_encapsulate(void *vctx, unsigned char *out, size_t *outlen,
*secretlen = 0; /* replace with real shared secret length */

if (out == NULL) {
debug_print("encaps outlens set to %d and %d\n", *outlen, *secretlen);
if (outlen != NULL && secretlen != NULL)
debug_print("encaps outlens set to %d and %d\n", *outlen, *secretlen);
return 1;
}

Expand All @@ -164,7 +165,8 @@ static int template_decapsulate(void *vctx, unsigned char *out, size_t *outlen,
*outlen = 0; /* replace with shared secret length */

if (out == NULL) {
debug_print("decaps outlen set to %d \n", *outlen);
if (outlen != NULL)
debug_print("decaps outlen set to %d \n", *outlen);
return 1;
}

Expand Down

0 comments on commit 5671a8d

Please sign in to comment.