From fbcdaf78bdb7233ef5d22bbad396de84bd897601 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 19 Mar 2025 15:30:59 +0100 Subject: [PATCH] fix conditional on undefined value on some config syntax errors if the first token on a line was an unterminated escape/quote, we'd branch based on an uninitialized 'comment' variable. amends 725a122e. --- src/config.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/config.c b/src/config.c index 3ea4837..6a98297 100644 --- a/src/config.c +++ b/src/config.c @@ -73,8 +73,8 @@ get_arg( conffile_t *cfile, int required, int *comment ) while ((c = *p) && isspace( (uchar)c )) p++; if (!c || c == '#') { - if (comment) - *comment = (c == '#'); + if (comment && c) + *comment = 1; if (required) { error( "%s:%d: parameter missing\n", cfile->file, cfile->line ); cfile->err = 1; @@ -313,7 +313,6 @@ int getcline( conffile_t *cfile ) { char *arg; - int comment; if (cfile->rest && (arg = get_arg( cfile, ARG_OPTIONAL, NULL ))) { error( "%s:%d: excess token '%s'\n", cfile->file, cfile->line, arg ); @@ -322,6 +321,7 @@ getcline( conffile_t *cfile ) while (fgets( cfile->buf, cfile->bufl, cfile->fp )) { cfile->line++; cfile->rest = cfile->buf; + int comment = 0; if (!(cfile->cmd = get_arg( cfile, ARG_OPTIONAL, &comment ))) { if (comment) continue;