From mboxrd@z Thu Jan 1 00:00:00 1970 From: cgit at cryptocrack.de (Lukas Fleischer) Date: Tue, 4 Jun 2013 17:43:06 +0200 Subject: [PATCH] Use strbuf for reading configuration files In-Reply-To: <1370357273-4532-1-git-send-email-cgit@cryptocrack.de> References: <20130604135705.GA15648@blizzard> <1370357273-4532-1-git-send-email-cgit@cryptocrack.de> Message-ID: <20130604154306.GA14674@blizzard> On Tue, Jun 04, 2013 at 04:47:53PM +0200, Lukas Fleischer wrote: > Use struct strbuf from Git instead of fixed-size buffers to remove the > limit on the length of configuration file lines and refactor > read_config_line() to improve readability. > > Note that this also fixes a buffer overflow that existed with the > original fixed-size buffer implementation. > > Signed-off-by: Lukas Fleischer > --- > configfile.c | 65 ++++++++++++++++++++++++++++++------------------------------ > configfile.h | 2 ++ > 2 files changed, 35 insertions(+), 32 deletions(-) > > diff --git a/configfile.c b/configfile.c > index d98989c..e6ad1d6 100644 > --- a/configfile.c > +++ b/configfile.c > @@ -31,45 +31,44 @@ static void skip_line(FILE *f) > [...] > + /* Skip comments and preceding spaces. */ > + while (c == '#' || c == ';') { > + skip_line(f); > + c = next_char(f); > + } > + while (isspace(c)) > + c = next_char(f); Just noticed that this no longer detects indented comments. Not sure if it makes sense to accept these (since we already only allow full fill-line comments) but given that no longer allowing them is probably considered a regression I will amend the patch and resubmit as far and as soon as there aren't any other comments. > + > + /* Read variable name. */ > [...]