Coverage Report

Created: 2023-03-26 06:06

/src/janus-gateway/fuzzers/sdp_fuzzer.c
Line
Count
Source (jump to first uncovered line)
1
#include <stdint.h>
2
#include <stddef.h>
3
#include <stdlib.h>
4
#include <string.h>
5
6
#include <glib.h>
7
#include "../src/debug.h"
8
#include "../src/sdp-utils.h"
9
10
int janus_log_level = LOG_NONE;
11
gboolean janus_log_timestamps = FALSE;
12
gboolean janus_log_colors = FALSE;
13
char *janus_log_global_prefix = NULL;
14
int lock_debug = 0;
15
int refcount_debug = 0;
16
17
/* This is to avoid linking with openSSL */
18
0
int RAND_bytes(uint8_t *key, int len) {
19
0
  return 0;
20
0
}
21
22
1.53k
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
23
  /* Since we're fuzzing SDP, and that in our case SDP always comes
24
   * from a Jansson call, this will need to be a valid string */
25
1.53k
  if(size <= 0)
26
0
    return 0;
27
1.53k
  char sdp_string[size];
28
1.53k
  memcpy(sdp_string, data, size);
29
1.53k
  sdp_string[size-1] = '\0';
30
  /* Parse the SDP using the utils */
31
1.53k
  char error_str[512];
32
1.53k
  janus_sdp *parsed_sdp = janus_sdp_parse((const char *)sdp_string, error_str, sizeof(error_str));
33
1.53k
  if(parsed_sdp == NULL)
34
1.18k
    return 0;
35
  /* Regenerate the SDP blog */
36
346
  char *generated_sdp = janus_sdp_write(parsed_sdp);
37
38
  /* Free resources */
39
346
  janus_sdp_destroy(parsed_sdp);
40
346
  g_free(generated_sdp);
41
42
346
  return 0;
43
1.53k
}