This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] nss_files: Avoid large buffers with many host addresses [BZ #22078]
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: Florian Weimer <fweimer at redhat dot com>, libc-alpha at sourceware dot org
- Date: Tue, 10 Oct 2017 15:41:11 -0300
- Subject: Re: [PATCH] nss_files: Avoid large buffers with many host addresses [BZ #22078]
- Authentication-results: sourceware.org; auth=none
- References: <20170904173210.3CE87439942E3@oldenburg.str.redhat.com> <2ed7620d-87be-74cd-f346-70f08e31a2d0@linaro.org> <6430d3c4-578c-c6bd-3074-b511223747bf@redhat.com>
On 10/10/2017 10:34, Florian Weimer wrote:
> On 09/05/2017 08:40 PM, Adhemerval Zanella wrote:
>>> +/* Type of the address and alias arrays. */
>>> +#define DYNARRAY_STRUCT array
>>> +#define DYNARRAY_ELEMENT char *
>>> +#define DYNARRAY_PREFIX array_
>>> +#include <malloc/dynarray-skeleton.c>
>>> +
>> This will create a 16 elements vector as default (128 bytes). Should we
>> aim to use the default or can we use a slight large buffer to speed up
>> slightly generic case (assuming generic case use more than 16 entries)?
>
> 16 elements is actually too large, I wouldn't expect more than 1 or 2 elements in the typical case. But we already have a scratch buffer on the stack, so I don't think it makes sense to override the default size to reduce stack usage.
>
> The rebased patch simplifies the code a bit, by eliminating the new_data variable. We now always copy back the addresses and aliases from the dynamic arrays. In addition, this allows us to reuse the space internal_getent allocated to the aliases array.
>
> Thanks,
> Florian
>
> bug22078.patch
LGTM.