1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 
3 #include <linux/hid.h>
4 #include <stdbool.h>
5 #include <stdint.h>
6 #include <stdlib.h>
7 
8 #include "fido_id_desc.h"
9 #include "fuzz.h"
10 #include "log.h"
11 
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)12 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
13         /* We don't want to fill the logs with messages about parse errors.
14          * Disable most logging if not running standalone */
15         if (!getenv("SYSTEMD_LOG_LEVEL"))
16                 log_set_max_level(LOG_CRIT);
17 
18         if (outside_size_range(size, 0, HID_MAX_DESCRIPTOR_SIZE))
19                 return 0;
20 
21         (void) is_fido_security_token_desc(data, size);
22 
23         return 0;
24 }
25