[SSSD] [PATCH] resolv_gethostbyname_dns_parse(): remove tmp_ctx

Lukas Slebodnik lslebodn at redhat.com
Fri Feb 14 13:37:24 UTC 2014


On (14/02/14 13:58), Pavel Březina wrote:
>On 02/14/2014 01:55 PM, Lukas Slebodnik wrote:
>>On (14/02/14 13:28), Pavel Březina wrote:
>>>https://fedorahosted.org/sssd/ticket/2198
>>
>>>From 7b36b3f479dab7216e52ce6865906f2ce0444bb7 Mon Sep 17 00:00:00 2001
>>>From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina at redhat.com>
>>>Date: Fri, 14 Feb 2014 13:04:31 +0100
>>>Subject: [PATCH] resolv_gethostbyname_dns_parse(): remove tmp_ctx
>>>
>>>Resolves:
>>>https://fedorahosted.org/sssd/ticket/2198
>>>---
>>>src/resolv/async_resolv.c | 8 ++------
>>>1 file changed, 2 insertions(+), 6 deletions(-)
>>>
>>>diff --git a/src/resolv/async_resolv.c b/src/resolv/async_resolv.c
>>>index 9770d3a179b051b0aae4dab6ad8d3057beac8015..439137099e33b7e683a5b6cc2cb810d69d526c15 100644
>>>--- a/src/resolv/async_resolv.c
>>>+++ b/src/resolv/async_resolv.c
>>>@@ -944,15 +944,11 @@ resolv_gethostbyname_dns_parse(struct gethostbyname_dns_state *state,
>>>                                int status, int timeouts,
>>>                                unsigned char *abuf, int alen)
>>>{
>>>-    TALLOC_CTX *tmp_ctx;
>>>     struct hostent *hostent;
>>>     int naddrttls;
>>>     errno_t ret;
>>>     void *addr;
>>>
>>>-    tmp_ctx = talloc_new(NULL);
>>>-    if (!tmp_ctx) return ENOMEM;
>>>-
>>>     naddrttls = DNS_HEADER_ANCOUNT(abuf);
>>>
>>>     switch (state->family) {
>>>@@ -1007,11 +1003,11 @@ resolv_gethostbyname_dns_parse(struct gethostbyname_dns_state *state,
>>>         }
>>>     }
>>>
>>>-    talloc_free(tmp_ctx);
>>>+    talloc_free(addr);
>>>     return return_code(status);
>>>
>>>fail:
>>>-    talloc_free(tmp_ctx);
>>>+    talloc_free(addr);
>>>     return ret;
>>
>>Warning from clang static analyser
>>
>>src/resolv/async_resolv.c:1010:5: warning: Function call argument is an uninitialized value
>>     talloc_free(addr);
>>     ^~~~~~~~~~~~~~~~~
>>/usr/include/talloc.h:226:26: note: expanded from macro 'talloc_free'
>>#define talloc_free(ctx) _talloc_free(ctx, __location__)
>>                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>1 warning generated.
>>
>>addr would not be initialised in defaul section.
>>I can see two options:
>>     - initialise addr to NULL
>>     - do not remove tmp_ctx, but to use tmp_ctx for allocation of array.
>>
>>LS
>
>Argh, I forgot to commit last change - initialize addr with NULL. New
>patch is attached.
>
>Thank you for review.
>

>From 2b6c8dd1458c0886f24afd832a9282b9d7cb8735 Mon Sep 17 00:00:00 2001
>From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina at redhat.com>
>Date: Fri, 14 Feb 2014 13:04:31 +0100
>Subject: [PATCH] resolv_gethostbyname_dns_parse(): remove tmp_ctx
>
>Resolves:
>https://fedorahosted.org/sssd/ticket/2198
>---
> src/resolv/async_resolv.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
>diff --git a/src/resolv/async_resolv.c b/src/resolv/async_resolv.c
>index 9770d3a179b051b0aae4dab6ad8d3057beac8015..505154c9daca2a15d95f48e8bbd0e8c909d91516 100644
>--- a/src/resolv/async_resolv.c

ACK

LS



More information about the sssd-devel mailing list