• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <stddef.h>
13 #include <stdint.h>
14 #include <stdlib.h>
15 
16 #include "apr_network_io.h"
17 
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)18 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
19   apr_pool_t *pool;
20   apr_pool_initialize();
21   if (apr_pool_create(&pool, NULL) != APR_SUCCESS) {
22     abort();
23   }
24 
25   char *addr = NULL;
26   char *scope_id = NULL;
27   apr_port_t port = 0;
28   char *input_string = strndup((const char *)data, size);
29 
30   apr_parse_addr_port(&addr, &scope_id, &port, input_string, pool);
31 
32   free(input_string);
33   apr_pool_destroy(pool);
34   apr_terminate();
35 
36   return 0;
37 }
38