bug-libunistring
[Top][All Lists]
Advanced

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

Re: [bug-libunistring] SIGSEGV on malloc() failure


From: Tim Rühsen
Subject: Re: [bug-libunistring] SIGSEGV on malloc() failure
Date: Sat, 26 Jan 2019 22:01:38 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

On 26.01.19 21:50, Bruno Haible wrote:
> [CCing bug-gnulib, since the function 'iconveh_open' comes from gnulib.]
> 
> Tim Rühsen wrote in
> <https://lists.gnu.org/archive/html/bug-libunistring/2019-01/msg00000.html>:
>> I just tested random malloc() failures and stumbled upon a SIGSEGV
>> (details below).
>>
>> Program received signal SIGSEGV, Segmentation fault.
>> 0x00007ffff7dd1f61 in __gconv_close (cd=0x0) at gconv_close.c:34
>> 34      gconv_close.c: Datei oder Verzeichnis nicht gefunden.
>> (gdb) bt
>> #0  0x00007ffff7dd1f61 in __gconv_close (cd=0x0) at gconv_close.c:34
>> #1  0x00007ffff7dd185f in iconv_close (cd=<optimized out>) at
>> iconv_close.c:35
>> #2  0x00007ffff7c3ddc3 in libunistring_iconveh_open () from
>> /usr/lib/x86_64-linux-gnu/libunistring.so.2
>> #3  0x00007ffff7c3dfcd in libunistring_mem_iconveh () from
>> /usr/lib/x86_64-linux-gnu/libunistring.so.2
> 
> Thanks for the report. The stack trace immediately tells me where
> the problem comes from. This patch should fix it.

Cool ! I really hesitated to send it since it was not easy to reproduce.

Thanks for all your great knowledge, skills and work !

Regards, Tim

> 
> It has been a long-standing bug (introduced on 2009-08-30).
> 
> 
> 2019-01-26  Bruno Haible  <address@hidden>
> 
>       striconveh: Fix use of uninitialized iconv_t.
>       Reported by Tim Rühsen <address@hidden> in
>       
> <https://lists.gnu.org/archive/html/bug-libunistring/2019-01/msg00000.html>.
>       * lib/striconveh.c (iconveh_open): Correct the iconv_close argument.
> 
> diff --git a/lib/striconveh.c b/lib/striconveh.c
> index d4cc503..91184be 100644
> --- a/lib/striconveh.c
> +++ b/lib/striconveh.c
> @@ -73,7 +73,7 @@ iconveh_open (const char *to_codeset, const char 
> *from_codeset, iconveh_t *cdp)
>          {
>            int saved_errno = errno;
>            if (cd != (iconv_t)(-1))
> -            iconv_close (cdp->cd);
> +            iconv_close (cd);
>            errno = saved_errno;
>            return -1;
>          }
> 
> 

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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