[PATCH] xfree86: check for NULL pointer before dereferences it in parser code

Dan Nicholson dbn.lists at gmail.com
Mon Apr 19 22:06:17 PDT 2010


On Mon, Apr 19, 2010 at 10:58 AM, Tiago Vignatti
<tiago.vignatti at nokia.com> wrote:
> Seems to be harmless. Meh.
>
> Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
> ---
>  hw/xfree86/parser/scan.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
> index 8aab0cf..06710d5 100644
> --- a/hw/xfree86/parser/scan.c
> +++ b/hw/xfree86/parser/scan.c
> @@ -845,10 +845,13 @@ static int
>  ConfigFilter(const struct dirent *de)
>  {
>        const char *name = de->d_name;
> -       size_t len = strlen(name);
> +       size_t len;
>        size_t suflen = strlen(XCONFIGSUFFIX);
>
> -       if (!name || name[0] == '.' || len <= suflen)
> +       if (!name || name[0] == '.')
> +               return 0;
> +       len = strlen(name);
> +       if(len <= suflen)
>                return 0;
>        if (strcmp(&name[len-suflen], XCONFIGSUFFIX) != 0)
>                return 0;
> --
> 1.6.0.4

There's still the outside possibility your platform's scandir could
pass a NULL dirent, but let's hope it's not that stupid.

Reviewed-by: Dan Nicholson <dbn.lists at gmail.com>


More information about the xorg-devel mailing list