1 #include <stdint.h>
2 #include <stddef.h>
3 #include <stdlib.h>
4 #include <string.h>
5 
6 #include <glib.h>
7 #include "../debug.h"
8 #include "../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 */
RAND_bytes(uint8_t * key,int len)18 int RAND_bytes(uint8_t *key, int len) {
19 	return 0;
20 }
21 
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)22 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 	if(size <= 0)
26 		return 0;
27 	char sdp_string[size];
28 	memcpy(sdp_string, data, size);
29 	sdp_string[size-1] = '\0';
30 	/* Parse the SDP using the utils */
31 	char error_str[512];
32 	janus_sdp *parsed_sdp = janus_sdp_parse((const char *)sdp_string, error_str, sizeof(error_str));
33 	if(parsed_sdp == NULL)
34 		return 0;
35 	/* Regenerate the SDP blog */
36 	char *generated_sdp = janus_sdp_write(parsed_sdp);
37 
38 	/* Free resources */
39 	janus_sdp_destroy(parsed_sdp);
40 	g_free(generated_sdp);
41 
42 	return 0;
43 }
44