[libiberty] fix unbounded alloca in make_relative_prefix_1

Bernd Schmidt bschmidt@redhat.com
Fri Jul 29 14:57:00 GMT 2016


On 07/29/2016 02:30 PM, Aldy Hernandez wrote:
> +/* Max number of alloca bytes per call before we must switch to malloc.
> +
> +   ?? Swiped from gnulib's regex_internal.h header.  Is this actually
> +   the case?  This number seems arbitrary, though sane.
> +
> +   The OS usually guarantees only one guard page at the bottom of the stack,
> +   and a page size can be as small as 4096 bytes.  So we cannot safely
> +   allocate anything larger than 4096 bytes.  Also care for the possibility
> +   of a few compiler-allocated temporary stack slots.  */
> +#define MAX_ALLOCA_SIZE	4032

The only question I have is whether this should be in the public 
libiberty.h header, or whether it's an internal value. If there's only 
one case in libiberty we could put the definition into that file.


Bernd



More information about the Gcc-patches mailing list