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

Vinitha Thejes Kuttian jiji.vinitha@gmail.com
Tue Sep 24 07:51:00 GMT 2013


Hi,
Sorry for no follow up.
Found that Andreas has proposed similar patch related to this bug - BZ #15048
http://sourceware.org/ml/libc-alpha/2013-01/msg00886.html.

Any comments ?

Regards,
Vinitha

On Mon, Sep 23, 2013 at 11:58 PM, Ondřej Bílka <neleai@seznam.cz> wrote:
>
> 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))



More information about the Libc-alpha mailing list