/src/coturn/fuzzing/FuzzStunClient.c
Line  | Count  | Source  | 
1  |  | #include <stdio.h>  | 
2  |  | #include <stdlib.h>  | 
3  |  | #include <string.h>  | 
4  |  |  | 
5  |  | #include "apputils.h"  | 
6  |  | #include "ns_turn_utils.h"  | 
7  |  | #include "stun_buffer.h"  | 
8  |  |  | 
9  | 460  | #define kMinInputLength 10  | 
10  | 224  | #define kMaxInputLength 5120  | 
11  |  |  | 
12  |  | extern int LLVMFuzzerTestOneInput(const uint8_t *Data,  | 
13  | 230  |                                   size_t Size) { // stunclient.c | 
14  |  |  | 
15  | 230  |   if (Size < kMinInputLength || Size > kMaxInputLength) { | 
16  | 25  |     return 1;  | 
17  | 25  |   }  | 
18  |  |  | 
19  | 205  |   stun_buffer buf;  | 
20  |  |  | 
21  | 205  |   buf.len = Size;  | 
22  | 205  |   memcpy(buf.buf, Data, buf.len);  | 
23  |  |  | 
24  | 205  |   if (stun_is_command_message(&buf)) { | 
25  | 57  |     if (stun_is_response(&buf)) { | 
26  | 49  |       if (stun_is_success_response(&buf)) { | 
27  | 36  |         if (stun_is_binding_response(&buf)) { | 
28  | 19  |           return 0;  | 
29  | 19  |         }  | 
30  | 36  |       }  | 
31  | 49  |     }  | 
32  | 57  |   }  | 
33  |  |  | 
34  | 186  |   return 1;  | 
35  | 205  | }  |