2 * A target program for fuzzing the XKB keymap text format.
4 * Currently, just parses an input file, and hopefully doesn't crash or hang.
9 #include "xkbcommon/xkbcommon.h"
12 main(int argc, char *argv[])
14 struct xkb_context *ctx;
16 struct xkb_keymap *keymap;
19 fprintf(stderr, "usage: %s <file>\n", argv[0]);
23 ctx = xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES | XKB_CONTEXT_NO_ENVIRONMENT_NAMES);
26 #ifdef __AFL_HAVE_MANUAL_CONTROL
29 while (__AFL_LOOP(1000))
32 file = fopen(argv[1], "r");
34 keymap = xkb_keymap_new_from_file(ctx, file,
35 XKB_KEYMAP_FORMAT_TEXT_V1,
36 XKB_KEYMAP_COMPILE_NO_FLAGS);
37 xkb_keymap_unref(keymap);
41 puts(keymap ? "OK" : "FAIL");
42 xkb_context_unref(ctx);