[PATCH] Use strbuf for reading configuration files

Lukas Fleischer cgit at cryptocrack.de
Tue Jun 4 17:43:06 CEST 2013


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 <cgit at cryptocrack.de>
> ---
>  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. */
> [...]


More information about the CGit mailing list