[PATCH v2 1/3] Fix __check_pf()/make_request() stack overflow segfault (convert to malloc)

Siddhesh Poyarekar siddhesh@redhat.com
Mon Jan 20 11:42:00 GMT 2014


On Fri, Jan 17, 2014 at 01:22:46AM +0100, Ondřej Bílka wrote:
> which only copies list into malloced array while preserving ordering.
> 
> A better way would be to malloc result at start and write into in6ai
> array directly, calling realloc to double size as necessary. At end we
> could optionally trim memory at end.
> 
> This should also be more effective as one big copy is faster when you
> need to copy same amount of data in small chunks.

Interface configuration shouldn't change all the time, so the
reallocation event ought to be infrequent enough that we need not
worry about it.  In fact in the common case of the interfaces not
changing, we should end up with just one allocation, with subsequent
getaddrinfo calls resulting in only copies.

nscd makes this even better by caching the interfaces so that the
query itself is avoided.

Siddhesh



More information about the Libc-alpha mailing list