[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: readelf [PATCH]

From: Nick Clifton
Subject: Re: readelf [PATCH]
Date: 06 Nov 2002 17:51:16 +0000
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.1

Hi Sergei,

> I have found a little bug in "readelf" this weekend.  Sometimes
> variable called "process_headers" may have NULL value

err you mean 'section_headers'

> and reading its members would fail.  For avoid this problem I have
> wrote little patch.  In the patch I have add few checks of variable
> process_headers like this: 
> if (process_headers != NULL)
> or
> if (process_headers == NULL)

This should not be necessary.  The functions that initialise
section_headers (either get_32bit_section_headers or
get_64bit_section_headers) should always return an error code if they
failed, and this should always be checked.  So the correct fix for the
bug is to find out where get_{32|64}bit_section_headers() is not
returning an error code, or where their return values are being
ignored and to fix these places.

How did you cause readelf to attempt to use section_headers when it
was not initialised ?

>  {
>    PTR mvar;
> -
> +  int err;
> +  int c;
> +  
>    if (size == 0)
>      return NULL;
> -  if (fseek (file, offset, SEEK_SET))
> +  err = fseek (file, offset, SEEK_SET);
> +  Ó = getc(file);
> +
> +  if ((Ó == EOF) || (err != 0))

Note - this appears to be a fix/hack for a completely unrelated
problem and should not have been included in this patch.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]