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.
10 #include "xkbcommon/xkbcommon.h"
13 main(int argc, char *argv[])
15 struct xkb_context *ctx;
17 struct xkb_keymap *keymap;
20 fprintf(stderr, "usage: %s <file>\n", argv[0]);
24 ctx = xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES | XKB_CONTEXT_NO_ENVIRONMENT_NAMES);
27 #ifdef __AFL_HAVE_MANUAL_CONTROL
30 while (__AFL_LOOP(1000))
33 file = fopen(argv[1], "r");
35 keymap = xkb_keymap_new_from_file(ctx, file,
36 XKB_KEYMAP_FORMAT_TEXT_V1,
37 XKB_KEYMAP_COMPILE_NO_FLAGS);
38 xkb_keymap_unref(keymap);
42 puts(keymap ? "OK" : "FAIL");
43 xkb_context_unref(ctx);