From 76578805baaee5ce86fa740146b440373d9b6187 Mon Sep 17 00:00:00 2001 From: Johannes Findeisen Date: Sun, 29 Nov 2026 04:17:07 +0100 Subject: [PATCH] Handle missing config arguments on musl --- irc9.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/irc9.c b/irc9.c index 77f1f38..b2c405e 100644 --- a/irc9.c +++ b/irc9.c @@ -649,11 +649,11 @@ static void load_config(const char *path) key = strtok_r(p, " \t", &save); if (!key) continue; if (strcasecmp(key, "name") == 0) { - save += strspn(save, " \t"); - size_t len = strlen(save); + if (save) save += strspn(save, " \t"); + size_t len = save ? strlen(save) : 0; while (len && (save[len - 1] == ' ' || save[len - 1] == '\t')) save[--len] = 0; - if (last && *save) { + if (last && len) { free(last->name); last->name = dupstr(save); } else { @@ -662,8 +662,8 @@ static void load_config(const char *path) continue; } if (strcasecmp(key, "autocommand") == 0) { - save += strspn(save, " \t"); - if (last && *save && strlen(save) <= MAXLINE - 2 && + if (save) save += strspn(save, " \t"); + if (last && save && *save && strlen(save) <= MAXLINE - 2 && !strchr(save, '\r')) { free(last->autocommand); last->autocommand = dupstr(save); @@ -684,11 +684,11 @@ static void load_config(const char *path) *channel_tail = channel; channel_tail = &channel->next; - save += strspn(save, " \t"); - if (*save == '/' && save[1] && strlen(save) < MAXINPUT && - !strchr(save, '\r')) - channel->command = dupstr(save); - else if (*save) + const char *command = save ? save + strspn(save, " \t") : ""; + if (*command == '/' && command[1] && strlen(command) < MAXINPUT && + !strchr(command, '\r')) + channel->command = dupstr(command); + else if (*command) fprintf(stderr, "irc9: ignoring invalid command for channel %s\n", a1); } #endif