[PATCH] nss_files: Avoid large buffers with many host addresses [BZ #22078]

Adhemerval Zanella adhemerval.zanella@linaro.org
Tue Oct 10 18:41:00 GMT 2017



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.



More information about the Libc-alpha mailing list