Potential Memory Leak in inn-2.6.0/lib/getaddrinfo.c

Russ Allbery eagle at eyrie.org
Wed Oct 14 19:08:52 UTC 2015


Bill Parker <wp02855 at gmail.com> writes:

>    In reviewing source code in inn-2.6.0, I found a call to strdup()
> in file 'getaddrinfo.c', which upon failure does not release the
> memory previously allocated to variable 'sin' via calloc().  The
> patch file below should address/correct this issue:

> --- getaddrinfo.c.orig  2015-10-12 18:34:50.194535147 -0700
> +++ getaddrinfo.c       2015-10-12 18:36:00.409459103 -0700
> @@ -217,6 +217,7 @@
>      else {
>          ai->ai_canonname = strdup(canonical);
>          if (ai->ai_canonname == NULL) {
> +            free(sin);
>              freeaddrinfo(ai);
>              return NULL;
>          }

Hi Bill,

sin is stored in the ai struct a few lines previous:

    ai->ai_addr = (struct sockaddr *) sin;

and therefore will be freed by freeaddrinfo(ai).

-- 
Russ Allbery (eagle at eyrie.org)              <http://www.eyrie.org/~eagle/>


More information about the inn-workers mailing list