[PATCH 7/8] nss: aiforaf: Decrease stack size by scoping off large buffers.
Kristina Hanicova
khanicov at redhat.com
Wed Aug 30 12:44:04 UTC 2023
On Wed, Aug 30, 2023 at 2:21 PM Peter Krempa <pkrempa at redhat.com> wrote:
> On Wed, Aug 30, 2023 at 13:59:21 +0200, Peter Krempa wrote:
> > The 'buf', 'sa' and 'hints' stack allocated helper variables are never
> > used together. Decrease the stack memory usage by scoping them off into
> > do-while blocks.
> >
> > In this instance we do not want to use dynamic allocation as this is the
> > NSS module.
> >
> > Signed-off-by: Peter Krempa <pkrempa at redhat.com>
> > ---
> > tools/nss/libvirt_nss.c | 97 +++++++++++++++++++++++------------------
> > 1 file changed, 54 insertions(+), 43 deletions(-)
> >
> > diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c
> > index 37720bf4ae..dff3c034bf 100644
> > --- a/tools/nss/libvirt_nss.c
> > +++ b/tools/nss/libvirt_nss.c
>
> [...]
>
> > - hints = *pai;
> > - hints.ai_flags = AI_NUMERICHOST;
> > - hints.ai_family = af;
> > + hints = *pai;
> > + hints.ai_flags = AI_NUMERICHOST;
> > + hints.ai_family = af;
> >
> > - if (getaddrinfo(host, NULL, &hints, &res0)) {
> > - addrList++;
> > - continue;
>
> Ehh, self-NACK ...
Apart from moving these two continue into loops...
>
>
> > - }
> > + if (getaddrinfo(host, NULL, &hints, &res0)) {
> > + addrList++;
> > + continue;
> > + }
> > + } while (false);
> >
> > for (res = res0; res; res = res->ai_next)
> > res->ai_flags = pai->ai_flags;
> > --
> > 2.41.0
> >
>
>
Reviewed-by: Kristina Hanicova <khanicov at redhat.com>
Kristina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20230830/24c3eaf1/attachment.htm>
More information about the libvir-list
mailing list