]>
git.ipfire.org Git - thirdparty/strongswan.git/blob - fuzz/fuzz_pa_tnc.c
2 * Copyright (C) 2018 Andreas Steffen
3 * HSR Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 #include <pa_tnc/pa_tnc_msg.h>
19 #include <ietf/ietf_attr_pa_tnc_error.h>
20 #include <utils/debug.h>
22 int LLVMFuzzerTestOneInput(const uint8_t *buf
, size_t len
)
26 ietf_attr_pa_tnc_error_t
*error
;
27 linked_list_t
*non_fatal_types
;
28 enumerator_t
*enumerator
;
31 dbg_default_set_level(-1);
32 library_init(NULL
, "fuzz_pa_tnc");
33 plugin_loader_add_plugindirs(PLUGINDIR
, PLUGINS
);
34 if (!lib
->plugins
->load(lib
->plugins
, PLUGINS
))
39 chunk
= chunk_create((u_char
*)buf
, len
);
41 /* Parse incoming PA-TNC message */
42 msg
= pa_tnc_msg_create_from_data(chunk
);
43 if (msg
->process(msg
) == SUCCESS
)
45 non_fatal_types
= linked_list_create();
46 msg
->process_ietf_std_errors(msg
, non_fatal_types
);
47 non_fatal_types
->destroy(non_fatal_types
);
50 /* enumerate correctly decoded attributes */
51 enumerator
= msg
->create_attribute_enumerator(msg
);
52 while (enumerator
->enumerate(enumerator
, &attr
))
54 attr
->get_noskip_flag(attr
);
56 enumerator
->destroy(enumerator
);
58 /* enumerate errors detected while parsing PA-TNC message and attributes */
59 enumerator
= msg
->create_error_enumerator(msg
);
60 while (enumerator
->enumerate(enumerator
, &attr
))
62 error
= (ietf_attr_pa_tnc_error_t
*)attr
;
63 error
->get_error_code(error
);
65 enumerator
->destroy(enumerator
);
70 lib
->plugins
->unload(lib
->plugins
);