This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] libdw: Don't overflow stack with user defined macro attributes array.


Mark Wielaard <mjw@redhat.com> writes:

> -      Dwarf_Attribute attributes[proto->nforms];
> +      Dwarf_Attribute *attributes;
> +      Dwarf_Attribute *attributesp = NULL;
> +      Dwarf_Attribute nattributes[8];
> +      if (unlikely (proto->nforms > 8))
> +	{
> +	  attributesp = malloc (sizeof (Dwarf_Attribute) * proto->nforms);
> +	  if (attributesp == NULL)
> +	    {
> +	      __libdw_seterrno (DWARF_E_NOMEM);
> +	      return -1;
> +	    }
> +	  attributes = attributesp;
> +	}
> +      else
> +	attributes = &nattributes[0];
> +
>        for (Dwarf_Word i = 0; i < proto->nforms; ++i)
>  	{

There's a return in this loop that needs free (attributesp) as well.

Thanks,
Petr

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]