Clean up tag_count config parsing; defensively clamp tag snprintf

This commit is contained in:
Gerry Hernandez 2026-03-09 19:13:01 -07:00
parent 8cc5579e16
commit 139f25a0b9
3 changed files with 4 additions and 3 deletions

View file

@ -1577,6 +1577,7 @@ bool parse_option(Config *config, char *key, char *value) {
config->default_nmaster = atoi(value);
} else if (strcmp(key, "tag_count") == 0) {
config->tag_count = CLAMP_INT(atoi(value), 1, 32);
tag_count = config->tag_count;
} else if (strcmp(key, "center_master_overspread") == 0) {
config->center_master_overspread = atoi(value);
} else if (strcmp(key, "center_when_single_stack") == 0) {
@ -3494,6 +3495,7 @@ bool parse_config(void) {
config.scroller_proportion_preset_count = 0;
config.circle_layout = NULL;
config.circle_layout_count = 0;
config.tag_count = 9;
config.tag_rules = NULL;
config.tag_rules_count = 0;
config.cursor_theme = NULL;

View file

@ -74,7 +74,7 @@ static const char *get_name_from_tag(uint32_t tag, char *buf, size_t len) {
return "overview";
if (tag > (uint32_t)tag_count)
return NULL;
snprintf(buf, len, "%u", tag);
snprintf(buf, len, "%u", CLAMP_INT(tag, 1, 32));
return buf;
}
@ -188,4 +188,4 @@ void workspaces_init() {
ext_manager = wlr_ext_workspace_manager_v1_create(dpy, 1);
/* Initialize the global workspaces list */
wl_list_init(&workspaces);
}
}

View file

@ -5456,7 +5456,6 @@ void setup(void) {
setenv("XDG_CURRENT_DESKTOP", "mango", 1);
parse_config();
tag_count = config.tag_count;
init_baked_points();
int32_t drm_fd, i, sig[] = {SIGCHLD, SIGINT, SIGTERM, SIGPIPE};