[PATCH] Fix resource leak - sockaddr is not properly freed

Lubos Uhliarik luhliari at redhat.com
Tue Mar 8 09:33:56 UTC 2022


Hi Maxim,

I'm sorry, it's my mistake I missed that

sin = &sockaddr[d].sockaddr_in;

and

dst[d].sockaddr = (struct sockaddr *) sin;

Sorry for the confusion.

Best,
Lubos

On Sun, Mar 6, 2022 at 2:59 AM Maxim Dounin <mdounin at mdounin.ru> wrote:

> Hello!
>
> On Thu, Mar 03, 2022 at 02:11:26AM +0100, Lubos Uhliarik wrote:
>
> >  # HG changeset patch
> > # User Lubos Uhliarik <luhliari at redhat.com>
> > # Date 1646269812 -3600
> > #      Thu Mar 03 02:10:12 2022 +0100
> > # Node ID 317e1e4b0c7343c49e0e13fc59ac75a565521b67
> > # Parent  a736a7a613ea6e182ff86fbadcb98bb0f8891c0b
> > Fix resource leak - sockaddr is not properly freed
> >
> > sockaddr variable is allocated by ngx_resolver_calloc function but then
> it
> > is
> > going out of scope leaking the storage it points to.
> >
> > diff -r a736a7a613ea -r 317e1e4b0c73 src/core/ngx_resolver.c
> > --- a/src/core/ngx_resolver.c   Tue Feb 08 17:35:27 2022 +0300
> > +++ b/src/core/ngx_resolver.c   Thu Mar 03 02:10:12 2022 +0100
> > @@ -4260,6 +4260,8 @@
> >      }
> >  #endif
> >
> > +    ngx_resolver_free(r, sockaddr);
> > +
> >      return dst;
> >  }
>
> Could you please clarify why do you think there is a leak?  Note
> that sockaddr is referenced in the dst array, which is being
> returned.
>
> --
> Maxim Dounin
> http://mdounin.ru/
> _______________________________________________
> nginx-devel mailing list -- nginx-devel at nginx.org
> To unsubscribe send an email to nginx-devel-leave at nginx.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20220308/c8b592c5/attachment.htm>


More information about the nginx-devel mailing list