[Slirp] [PATCH] Remove alloca() call in get_dns_addr_resolv_conf()

Philippe Mathieu-Daudé philmd at redhat.com
Fri May 7 15:03:16 UTC 2021


On 5/7/21 5:00 PM, Marc-André Lureau wrote:
> 
> 
> On Fri, May 7, 2021 at 5:32 PM Philippe Mathieu-Daudé <philmd at redhat.com
> <mailto:philmd at redhat.com>> wrote:
> 
>     The ALLOCA(3) man-page mentions its "use is discouraged".
> 
>     For now get_dns_addr_resolv_conf() is called with pointer to
>     a in_addr/in6_addr structure, and its size. Declare a union
>     of these structures on the stack, able to hold both of them.
>     This allows us to remove the alloca() call, keeping the buffer
>     on the stack.
> 
>     Add an assertion in the unlikely case another inet address
>     is handled by this function.
> 
>     Signed-off-by: Philippe Mathieu-Daudé <philmd at redhat.com
>     <mailto:philmd at redhat.com>>
> 
> 
> 
>     ---
>     Sorry no pull-req, I don't have my 2FA token with me.
> 
> 
> Made one for you and merged it:
> https://gitlab.freedesktop.org/slirp/libslirp/-/merge_requests/84

Thank you Marc-André!



More information about the Slirp mailing list