[PATCH v2 1/1] nscd: replace alloca with malloc in aicache, hstcache [BZ #34624]

Florian Weimer fweimer@redhat.com
Fri Sep 25 21:33:49 GMT 2026


* DJ Delorie:

> On Fri, Sep 25, 2026 at 2:45 PM Adhemerval Zanella Netto
> <adhemerval.zanella@linaro.org> wrote:
>> >   temporary memory.  */
>> > -      dataset = (struct dataset *) alloca (total + req->key_len);
>> > +      dataset = (struct dataset *) malloc (total + req->key_len);
>> > +      if (dataset == NULL)
>> > + goto next_nip;
>> >
>>
>> I think this makes the client see a negative answer when the failure was memory
>> exhaustion, because status[1] == NSS_STATUS_SUCCESS at this point.  I think it
>> should go to 'out', similar to scratch_buffer_grow failure.
>
> Changing out "out" is easy.  I couldn't really see a way to indicate
> an internal error, as nothing else in that function *sets* h_errno.
> NSS_INTERNAL is something the getXXbyYY functions return, but not via
> h_errno.  These functions don't really *return* anything, they're
> responses to requests, wouldn't they need to signal some status back
> to the client?  addhstaiX in this case is "insert key into database"
> and doesn't document how failure is signalled.
>
> Is "do nothing" even a valid response here?

We already do nothing if the memory allocation failure is one of the NSS
callbacks.

I expected that we'd send an explicit error response over the socket,
but instead we just close it.  This causes the client to fall back to a
direct, in-process NSS call.  Which is the expected behavior if nscd
cannot serve requests.

Thanks,
Florian



More information about the Libc-alpha mailing list