Skip to content

Commit ccb63bf

Browse files
committed
registry: Reject unsupported flags
1 parent 877640c commit ccb63bf

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

changes/api/+reject-unsupported-flags.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ Fixed some functions accepting unsupported flags:
22
- `xkb_context_new()`
33
- `xkb_rmlvo_builder_new()`
44
- `xkb_compose_state_new()`
5+
- `rxkb_context_new()`

src/registry.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,19 @@ rxkb_context_new(enum rxkb_context_flags flags)
512512
if (env)
513513
rxkb_context_set_log_level(ctx, log_level(env));
514514

515+
static const enum rxkb_context_flags RXKB_CONTEXT_FLAGS
516+
= RXKB_CONTEXT_NO_DEFAULT_INCLUDES
517+
| RXKB_CONTEXT_LOAD_EXOTIC_RULES
518+
| RXKB_CONTEXT_NO_SECURE_GETENV;
519+
520+
if (flags & ~RXKB_CONTEXT_FLAGS) {
521+
log_err(ctx, XKB_LOG_MESSAGE_NO_ID,
522+
"%s: Invalid context flags: 0x%x\n", __func__,
523+
(flags & ~RXKB_CONTEXT_FLAGS));
524+
free(ctx);
525+
return NULL;
526+
}
527+
515528
list_init(&ctx->models);
516529
list_init(&ctx->layouts);
517530
list_init(&ctx->option_groups);

test/registry.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,10 @@ main(void)
11271127
{
11281128
test_init();
11291129

1130+
/* Reject unsupported flags */
1131+
assert(!rxkb_context_new(-1));
1132+
assert(!rxkb_context_new(0xffff));
1133+
11301134
test_xml_error_handler();
11311135
test_no_include_paths();
11321136
test_invalid_include();

0 commit comments

Comments
 (0)