Coverage Report

Created: 2025-07-23 07:04

/src/samba/lib/fuzzing/fuzz_sess_crypt_blob.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
   Fuzzing sess_*crypt_blob
3
   Copyright (C) Catalyst IT 2020
4
5
   This program is free software; you can redistribute it and/or modify
6
   it under the terms of the GNU General Public License as published by
7
   the Free Software Foundation; either version 3 of the License, or
8
   (at your option) any later version.
9
10
   This program is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
   GNU General Public License for more details.
14
15
   You should have received a copy of the GNU General Public License
16
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
*/
18
#include "includes.h"
19
#include "fuzzing/fuzzing.h"
20
#include "libcli/auth/libcli_auth.h"
21
#include "session.h"
22
23
int LLVMFuzzerInitialize(int *argc, char ***argv)
24
372
{
25
372
  return 0;
26
372
}
27
28
29
int LLVMFuzzerTestOneInput(const uint8_t *input, size_t len)
30
272
{
31
272
  TALLOC_CTX *mem_ctx = NULL;
32
272
  DATA_BLOB blob, session_key, out;
33
272
  size_t slen;
34
272
  if (len < 1) {
35
0
    return 0;
36
0
  }
37
38
272
  slen = input[0];
39
272
  if (len < slen + 1) {
40
11
    return 0;
41
11
  }
42
43
261
  session_key.data = input + 1;
44
261
  session_key.length = slen;
45
261
  blob.data = input + 1 + slen;
46
261
  blob.length = len - slen - 1;
47
48
261
  mem_ctx = talloc_new(NULL);
49
50
261
  out = sess_encrypt_blob(mem_ctx, &blob, &session_key);
51
261
  sess_decrypt_blob(mem_ctx, &blob, &session_key, &out);
52
53
261
  TALLOC_FREE(mem_ctx);
54
261
  return 0;
55
272
}