This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2 1/3] Fix __check_pf()/make_request() stack overflow segfault (convert to malloc)
- From: Siddhesh Poyarekar <siddhesh at redhat dot com>
- To: OndÅej BÃlka <neleai at seznam dot cz>
- Cc: "Banerjee, Debabrata" <dbanerje at akamai dot com>, "Pengcheng dot Chen at gmail dot com" <Pengcheng dot Chen at gmail dot com>, "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>, "Carlos O'Donell" <carlos at redhat dot com>
- Date: Mon, 20 Jan 2014 17:11:39 +0530
- Subject: Re: [PATCH v2 1/3] Fix __check_pf()/make_request() stack overflow segfault (convert to malloc)
- Authentication-results: sourceware.org; auth=none
- References: <524E4504 dot 6050603 at redhat dot com> <1383268213-14349-1-git-send-email-dbanerje at akamai dot com> <20140116225341 dot GA23189 at domone dot podge> <CEFDCD71 dot 2C670%dbanerje at akamai dot com> <20140117002246 dot GA14011 at domone dot podge>
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