Coverage Report

Created: 2025-11-24 06:45

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/mosquitto/fuzzing/libcommon/libcommon_fuzz_topic_tokenise.cpp
Line
Count
Source
1
/*
2
Copyright (c) 2023 Cedalo GmbH
3
4
All rights reserved. This program and the accompanying materials
5
are made available under the terms of the Eclipse Public License 2.0
6
and Eclipse Distribution License v1.0 which accompany this distribution.
7
8
The Eclipse Public License is available at
9
   https://www.eclipse.org/legal/epl-2.0/
10
and the Eclipse Distribution License is available at
11
  http://www.eclipse.org/org/documents/edl-v10.php.
12
13
SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
14
15
Contributors:
16
   Roger Light - initial implementation and documentation.
17
*/
18
#include <mosquitto.h>
19
#include <cstdlib>
20
#include <cstring>
21
22
23
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
24
153
{
25
153
  char *buf;
26
153
  buf = (char *)calloc(1, size+1); /* ensure ull terminated */
27
153
  if(buf){
28
153
    char **topics = NULL;;
29
153
    int count;
30
31
153
    memcpy(buf, data, size);
32
153
    mosquitto_sub_topic_tokenise(buf, &topics, &count);
33
153
    mosquitto_sub_topic_tokens_free(&topics, count);
34
153
    free(buf);
35
153
  }
36
153
  return 0;
37
153
}