[PATCH weston] shared/config-parser: Allow spaces/tabs at the end for

Daniel Stone daniel at fooishbar.org
Sun Jul 22 10:49:23 UTC 2018


Hi Marius,
On Wed, 21 Feb 2018 at 14:38, Marius Vlad <marius-cristian.vlad at nxp.com> wrote:
> @@ -456,6 +457,10 @@ weston_config_parse(const char *name)
>                         section = config_add_section(config, &line[1]);
>                         continue;
>                 default:
> +                       start_line = stop_line = line;
> +                       while (stop_line && *stop_line != ' ' && *stop_line != '\t')

Should this be *stop_line? The pointer itself will never be NULL, so
it seems like this might read a long way out of bounds.

> @@ -474,7 +479,9 @@ weston_config_parse(const char *name)
>                                 p[i - 1] = '\0';
>                                 i--;
>                         }
> -                       section_add_entry(section, line, p);
> +
> +                       start_line[stop_line - start_line] = '\0';

I think you could remove the start_line variable and continue to just
use 'line' here, if you simplified this to *stop_line = '\0';

This should also have a few tests in config-parser-test.

Cheers,
Daniel


More information about the wayland-devel mailing list