Coverage Report

Created: 2026-03-06 06:32

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ndpi/fuzz/fuzz_alg_quick_encryption.cpp
Line
Count
Source
1
#include "ndpi_api.h"
2
#include "fuzz_common_code.h"
3
4
#include <stdlib.h>
5
#include <stdint.h>
6
#include "fuzzer/FuzzedDataProvider.h"
7
8
9
229
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
10
229
  FuzzedDataProvider fuzzed_data(data, size);
11
229
  char *enc_buffer, *dec_buffer;
12
229
  u_int16_t encrypted_msg_len, decrypted_msg_len;
13
14
229
  if(fuzzed_data.remaining_bytes() <= 64) /* Some data */
15
11
    return -1;
16
17
  /* To allow memory allocation failures */
18
218
  fuzz_set_alloc_callbacks_and_seed(size);
19
20
218
  std::vector<unsigned char>key = fuzzed_data.ConsumeBytes<u_int8_t>(64);
21
218
  std::vector<char>cleartext_msg = fuzzed_data.ConsumeRemainingBytes<char>();
22
23
218
  enc_buffer = ndpi_quick_encrypt(cleartext_msg.data(), cleartext_msg.size(), &encrypted_msg_len, key.data());
24
218
  if(enc_buffer) {
25
209
    dec_buffer = ndpi_quick_decrypt(enc_buffer, encrypted_msg_len, &decrypted_msg_len, key.data());
26
209
    ndpi_free(enc_buffer);
27
209
    ndpi_free(dec_buffer);
28
209
  }
29
218
  return 0;
30
229
}