This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix leak in gataddrinfo when /etc/nsswitch.conf is absent


Adding Vinitha to cc.

On Tue, Sep 10, 2013 at 02:34:02PM +1000, Allan McRae wrote:
> From: Vinitha Vijayan <jiji.vinitha@gmail.com>
> 
> ---
> 
> Patch submitted to the bug tracker without follow-up.  Siddhesh gave it an
> OK on the bug tracker.  I believe this is too small to require a contributor
> agreement.
> 
> OK to apply?
>
That patch looks ok, but as nip is in both branches it could be
equivalently written as below.
 
> 2013-09-10  Vinitha Vijayan  <jiji.vinitha@gmail.com>
> 
> 	[BZ #15048]
> 	* sysdeps/posix/getaddrinfo.c (gaih_inet): Fix memory leak.
> 
> 
>  sysdeps/posix/getaddrinfo.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
> index c0ded84..c9a97d4 100644
> --- a/sysdeps/posix/getaddrinfo.c
> +++ b/sysdeps/posix/getaddrinfo.c
> @@ -797,9 +797,12 @@ gaih_inet (const char *name, const struct gaih_service *service,
>  	      nip = __nss_hosts_database;

>  	    }
>  	  else
> -	    no_more = __nss_database_lookup ("hosts", NULL,
> -					     "dns [!UNAVAIL=return] files",
> -					     &nip);
> +	    {
> +	      no_more = __nss_database_lookup ("hosts", NULL,
> +					       "dns [!UNAVAIL=return] files",
> +					       &__nss_hosts_database);
> +	      nip = __nss_hosts_database;
> +	    }
>  
>  	  /* Initialize configurations.  */
>  	  if (__glibc_unlikely (!_res_hconf.initialized))
> -- 
> 1.8.4

diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 52177e4..5c80098 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -792,14 +792,12 @@ gaih_inet (const char *name, const struct gaih_service *service,
 #endif
 
 	  if (__nss_hosts_database != NULL)
-	    {
-	      no_more = 0;
-	      nip = __nss_hosts_database;
-	    }
+	    no_more = 0;
 	  else
 	    no_more = __nss_database_lookup ("hosts", NULL,
 					     "dns [!UNAVAIL=return] files",
-					     &nip);
+					     &__nss_hosts_database);
+	  nip = __nss_hosts_database;
 
 	  /* Initialize configurations.  */
 	  if (__glibc_unlikely (!_res_hconf.initialized))


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]