[PATCH] elflint: Always print symbol name (if known) in error messages.

Dmitry V. Levin ldv@altlinux.org
Tue Dec 15 23:05:16 GMT 2020


Hi Mark,

On Tue, Dec 15, 2020 at 11:53:48PM +0100, Mark Wielaard wrote:
> Hi Dmitry,
> 
> On Wed, Dec 16, 2020 at 12:44:05AM +0300, Dmitry V. Levin wrote:
> > This is nice, thanks.
> > I have one question about the patch:
> > 
> > [...]
> > > --- a/src/elflint.c
> > > +++ b/src/elflint.c
> > > @@ -706,7 +706,7 @@ section [%2d] '%s': XINDEX for zeroth entry not zero\n"),
> > >  	  continue;
> > >  	}
> > >  
> > > -      const char *name = NULL;
> > > +      const char *name = "<invalid>";
> > 
> > This variable is used in some checks, for example, it's being passed
> > to ebl_check_special_symbol.  I'd like to make sure this change
> > doesn't have any unintended consequences.
> 
> Good question. I assumed it was ok, but double checked.  It is used by
> ebl_check_special_symbol and various strcmps.  The strcmps would
> actually have crashed if the name was NULL (all backends that
> implement check_special_symbol did handle NULL first before calling
> strcmp). Since "<invalid>" isn't a valid symbol name (the '<' and '>'
> are not normally used) it is fine in all places that use name to check
> against a valid symbol name.

So this change is also a fix of potential null dereferences.
Looks good, thanks for double checking.


-- 
ldv


More information about the Elfutils-devel mailing list