1 /* Copyright 2021 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 13 #include "config.h" 14 #include "syshead.h" 15 #include "dhcp.h" 16 #include "buffer.h" 17 18 #include "fuzz_randomizer.h" 19 LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)20int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { 21 struct buffer ipbuf; 22 in_addr_t ret; 23 24 fuzz_random_init(data, size); 25 char *ran_val = get_random_string(); 26 27 ipbuf = alloc_buf(strlen(ran_val)); 28 if (buf_write(&ipbuf, ran_val, strlen(ran_val)) != false) { 29 ret = dhcp_extract_router_msg(&ipbuf); 30 } 31 free_buf(&ipbuf); 32 33 fuzz_random_destroy(); 34 free(ran_val); 35 36 return 0; 37 } 38