help-libidn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NULL check missing in lib/idna.c


From: Simon Josefsson
Subject: Re: NULL check missing in lib/idna.c
Date: Thu, 02 Aug 2012 22:18:55 +0200
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/23.3 (gnu/linux)

Sarat Chandra Addepalli <address@hidden> writes:

> Hello.
>
>  
>
> In the function idna_to_ascii_4i() in lib/idna.c, at the end of step
> 2, the call src = stringprep_utf8_to_ucs4(p, -1, NULL) may result in
> a NULL return. This needs to be checked, and if that's the case, p
> needs to be freed and the function should return with an #Idna_rc
> error code. IMHO, NULL return occurs only in the case of a malloc
> fail (due to g_malloc() in the function g_utf8_to_ucs4_fast), so the
> error code should be IDNA_MALLOC_ERROR.

Hello,

Thanks for the report!  I agree with your analysis and patch.  I have
applied it to git master for the next release.

/Simon

> diff --git a/lib/idna.c b/lib/idna.c
> index 9ab413c..12889cd 100644
> --- a/lib/idna.c
> +++ b/lib/idna.c
> @@ -154,6 +154,8 @@ idna_to_ascii_4i (const uint32_t * in, size_t inlen, char 
> *out, int flags)
>      src = stringprep_utf8_to_ucs4 (p, -1, NULL);
>  
>      free (p);
> +     if (!src)
> +             return IDNA_MALLOC_ERROR;
>    }
>  
>  step3:
>
> _______________________________________________
> Help-libidn mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-libidn



reply via email to

[Prev in Thread] Current Thread [Next in Thread]