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

Peter Hutterer peter.hutterer at who-t.net
Mon Apr 19 17:23:30 PDT 2010


On Mon, Apr 19, 2010 at 08:58:02PM +0300, Tiago Vignatti 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

Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

 
Cheers,
  Peter


More information about the xorg-devel mailing list