|
| 1 | +#include "ada_c.h" |
| 2 | + |
| 3 | +#include <stdbool.h> |
| 4 | +#include <stdio.h> |
| 5 | +#include <stdlib.h> |
| 6 | +#include <string.h> |
| 7 | + |
| 8 | +int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
| 9 | + /** |
| 10 | + * ada_c |
| 11 | + */ |
| 12 | + ada_url out = ada_parse((char*)data, size); |
| 13 | + bool is_valid = ada_is_valid(out); |
| 14 | + |
| 15 | + if (is_valid) { |
| 16 | + ada_set_href(out, (char*)data, size); |
| 17 | + ada_set_host(out, (char*)data, size); |
| 18 | + ada_set_hostname(out, (char*)data, size); |
| 19 | + ada_set_protocol(out, (char*)data, size); |
| 20 | + ada_set_username(out, (char*)data, size); |
| 21 | + ada_set_password(out, (char*)data, size); |
| 22 | + ada_set_port(out, (char*)data, size); |
| 23 | + ada_set_pathname(out, (char*)data, size); |
| 24 | + ada_set_search(out, (char*)data, size); |
| 25 | + ada_set_hash(out, (char*)data, size); |
| 26 | + |
| 27 | + ada_get_hash(out); |
| 28 | + ada_get_host(out); |
| 29 | + ada_get_host_type(out); |
| 30 | + ada_get_hostname(out); |
| 31 | + ada_get_href(out); |
| 32 | + ada_owned_string out_get_origin = ada_get_origin(out); |
| 33 | + ada_get_pathname(out); |
| 34 | + ada_get_username(out); |
| 35 | + ada_get_password(out); |
| 36 | + ada_get_protocol(out); |
| 37 | + ada_get_port(out); |
| 38 | + ada_get_search(out); |
| 39 | + ada_get_scheme_type(out); |
| 40 | + |
| 41 | + ada_has_credentials(out); |
| 42 | + ada_has_empty_hostname(out); |
| 43 | + ada_has_hostname(out); |
| 44 | + ada_has_non_empty_username(out); |
| 45 | + ada_has_non_empty_password(out); |
| 46 | + ada_has_port(out); |
| 47 | + ada_has_password(out); |
| 48 | + ada_has_hash(out); |
| 49 | + ada_has_search(out); |
| 50 | + |
| 51 | + ada_get_components(out); |
| 52 | + |
| 53 | + ada_clear_port(out); |
| 54 | + ada_clear_hash(out); |
| 55 | + ada_clear_search(out); |
| 56 | + |
| 57 | + ada_free_owned_string(out_get_origin); |
| 58 | + } |
| 59 | + |
| 60 | + bool can_parse_result = ada_can_parse((char*)data, size); |
| 61 | + |
| 62 | + ada_free(out); |
| 63 | + |
| 64 | + return 0; |
| 65 | +} |
0 commit comments