File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -492,6 +492,12 @@ log_level(const char *level) {
492492 return RXKB_LOG_LEVEL_ERROR ;
493493}
494494
495+ enum {
496+ RXKB_CONTEXT_FLAGS = RXKB_CONTEXT_NO_DEFAULT_INCLUDES
497+ | RXKB_CONTEXT_LOAD_EXOTIC_RULES
498+ | RXKB_CONTEXT_NO_SECURE_GETENV
499+ };
500+
495501struct rxkb_context *
496502rxkb_context_new (enum rxkb_context_flags flags )
497503{
@@ -512,6 +518,14 @@ rxkb_context_new(enum rxkb_context_flags flags)
512518 if (env )
513519 rxkb_context_set_log_level (ctx , log_level (env ));
514520
521+ if (flags & ~(enum rxkb_context_flags ) RXKB_CONTEXT_FLAGS ) {
522+ log_err (ctx , XKB_LOG_MESSAGE_NO_ID ,
523+ "%s: Invalid context flags: 0x%x\n" , __func__ ,
524+ (flags & ~(enum rxkb_context_flags ) RXKB_CONTEXT_FLAGS ));
525+ free (ctx );
526+ return NULL ;
527+ }
528+
515529 list_init (& ctx -> models );
516530 list_init (& ctx -> layouts );
517531 list_init (& ctx -> option_groups );
Original file line number Diff line number Diff line change @@ -1126,6 +1126,10 @@ main(void)
11261126{
11271127 test_init ();
11281128
1129+ /* Reject unsupported flags */
1130+ assert (!rxkb_context_new (-1 ));
1131+ assert (!rxkb_context_new (0xffff ));
1132+
11291133 test_xml_error_handler ();
11301134 test_no_include_paths ();
11311135 test_invalid_include ();
You can’t perform that action at this time.
0 commit comments