This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
Re: [PATCH] libdw: Don't overflow stack with user defined macro attributes array.
- From: Petr Machata <pmachata at gmail dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Tue, 21 Apr 2015 16:22:53 +0200
- Subject: 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