Handle missing config arguments on musl

This commit is contained in:
Johannes Findeisen 2026-11-29 04:17:07 +01:00
commit 76578805ba

20
irc9.c
View file

@ -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