Coverage Report

Created: 2025-01-28 06:43

/src/fuzz_hci.c
Line
Count
Source (jump to first uncovered line)
1
/* Copyright 2022 Google LLC
2
Licensed under the Apache License, Version 2.0 (the "License");
3
you may not use this file except in compliance with the License.
4
You may obtain a copy of the License at
5
      http://www.apache.org/licenses/LICENSE-2.0
6
Unless required by applicable law or agreed to in writing, software
7
distributed under the License is distributed on an "AS IS" BASIS,
8
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
See the License for the specific language governing permissions and
10
limitations under the License.
11
*/
12
#include <config.h>
13
14
#include <stdint.h>
15
#include <string.h>
16
#include <stdlib.h>
17
#include <syslog.h>
18
19
#include "bluetooth.h"
20
#include "sdp.h"
21
#include "sdp_lib.h"
22
#include "hci_lib.h"
23
24
25
0
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
26
0
  int to_copy = size;
27
0
  uint8_t features[8];
28
29
0
  if (size > 8) {
30
0
    to_copy = 8;
31
0
  }
32
33
0
  char *null_terminated = malloc(to_copy+1);
34
0
  memcpy(null_terminated, data, to_copy);
35
0
  null_terminated[to_copy] = '\0';
36
/*
37
  char *tmp = lmp_featurestostr(features, null_terminated, to_copy);
38
  if (tmp) {
39
    free(tmp);
40
  }
41
*/
42
0
  char *tmp = NULL;
43
44
0
  size -= to_copy;
45
0
  data += to_copy;
46
47
  /*
48
  uint8_t cmds[64];
49
  bzero(cmds, 64);
50
  for (int i = 0; i < 64 && i < size; i++) {
51
    cmds[i] = data[i];
52
  }
53
  tmp = hci_commandstostr(cmds, NULL, 0);
54
  if (tmp) {
55
    free(tmp);
56
  }
57
  */
58
0
  if (size > 4) {
59
0
    uint16_t id = *(uint16_t*)data;
60
0
    bt_compidtostr(id);
61
0
  }
62
63
0
  free(null_terminated);
64
0
  return 0;
65
0
}