[pulseaudio-discuss] [PATCH 2/3] pa_get_fqdn: always free addrinfo

Tanu Kaskinen tanuk at iki.fi
Fri Sep 11 04:20:39 PDT 2015


On Thu, 2015-09-10 at 21:42 -0300, Felipe Sateler wrote:
> Found by coverity
> ---
>  src/pulse/util.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/pulse/util.c b/src/pulse/util.c
> index 305673f..e4e8207 100644
> --- a/src/pulse/util.c
> +++ b/src/pulse/util.c
> @@ -311,8 +311,11 @@ char *pa_get_fqdn(char *s, size_t l) {
>      hints.ai_family = AF_UNSPEC;
>      hints.ai_flags = AI_CANONNAME;
>  
> -    if (getaddrinfo(hn, NULL, &hints, &a) < 0 || !a || !a
> ->ai_canonname || !*a->ai_canonname)
> +    if (getaddrinfo(hn, NULL, &hints, &a) < 0 || !a || !a
> ->ai_canonname || !*a->ai_canonname) {
> +        if (a)
> +            freeaddrinfo(a);
>          return pa_strlcpy(s, hn, l);
> +    }

I don't know if getaddrinfo() is guaranteed to always initialize a, but
if not, this code may access a while it's uninitialized. I think we
should initialize a to NULL.

-- 
Tanu


More information about the pulseaudio-discuss mailing list