• 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 "apr.h"
13 #include "apr_file_io.h"
14 #include "apr_poll.h"
15 #include "apr_portable.h"
16 #include "apr_proc_mutex.h"
17 #include "apr_signal.h"
18 #include "apr_strings.h"
19 #include "apr_thread_mutex.h"
20 #include "apr_thread_proc.h"
21 
22 #define APR_WANT_STRFUNC
23 #include "apr_file_io.h"
24 #include "apr_fnmatch.h"
25 #include "apr_want.h"
26 
27 #include "apr_poll.h"
28 #include "apr_want.h"
29 
30 #include "apr_uri.h"
31 
32 #include "ap_config.h"
33 #include "ap_expr.h"
34 #include "ap_listen.h"
35 #include "ap_provider.h"
36 #include "ap_regex.h"
37 
38 #include "ada_fuzz_header.h"
39 
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)40 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
41   af_gb_init();
42   const uint8_t *data2 = data;
43   size_t size2 = size;
44 
45   // Get a NULL terminated string
46   char *cstr = af_gb_get_null_terminated(&data2, &size2);
47 
48   // Fuzz URI routines
49   if (cstr && apr_pool_initialize() == APR_SUCCESS) {
50     apr_pool_t *pool = NULL;
51     apr_pool_create(&pool, NULL);
52 
53     apr_uri_t tmp_uri;
54     if (apr_uri_parse(pool, cstr, &tmp_uri) == APR_SUCCESS) {
55       apr_uri_unparse(pool, &tmp_uri, 0);
56     }
57     apr_uri_parse_hostinfo(pool, cstr, &tmp_uri);
58 
59     // Cleanup
60     apr_pool_terminate();
61   }
62 
63   af_gb_cleanup();
64   return 0;
65 }
66