diff options
author | Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> | 2024-11-01 18:17:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-01 18:17:22 +0100 |
commit | b63f74a0806ed9d6b80e81e0232ce94a095f1951 (patch) | |
tree | 3321ff59ba91f294100595a794e145d7fb06a463 /src | |
parent | 137d87fd873197f0fe43f627a90203e1696fdb2c (diff) |
fuzz: improve coverage (#2612)
Add fuzzer to test `ndpi_quick_encrypt()` and `ndpi_quick_decrypt()`
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/ndpi_utils.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/lib/ndpi_utils.c b/src/lib/ndpi_utils.c index a51f6c059..6aefc20e2 100644 --- a/src/lib/ndpi_utils.c +++ b/src/lib/ndpi_utils.c @@ -3810,7 +3810,8 @@ char* ndpi_quick_encrypt(const char *cleartext_msg, encoded = ndpi_base64_encode((const unsigned char *)encoded_buf, encoded_len); ndpi_free(encoded_buf); - *encrypted_msg_len = strlen(encoded); + if(encoded) + *encrypted_msg_len = strlen(encoded); return(encoded); } @@ -3842,13 +3843,15 @@ char* ndpi_quick_decrypt(const char *encrypted_msg, if((content == NULL) || (content_len == 0)) { /* Base64 decoding error */ + ndpi_free(decoded_string); ndpi_free(content); return(NULL); } if(allocated_decoded_string < (content_len+1)) { /* Buffer size failure */ - free(content); + ndpi_free(decoded_string); + ndpi_free(content); return(NULL); } |