This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Mangle NULL pointers in iconv/gconv [BZ #22025]
- From: Florian Weimer <fweimer at redhat dot com>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: GNU C Library <libc-alpha at sourceware dot org>, Patsy Franklin <pfrankli at redhat dot com>, Jeff Law <law at redhat dot com>
- Date: Tue, 29 Aug 2017 16:55:02 +0200
- Subject: Re: [PATCH] Mangle NULL pointers in iconv/gconv [BZ #22025]
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=fweimer at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 41AFA81E0B
- References: <50ea6b93-b58a-fdad-c178-a188ff6b6728@redhat.com> <mvmh8wqjxbx.fsf@suse.de>
On 08/29/2017 03:52 PM, Andreas Schwab wrote:
> On Aug 29 2017, Florian Weimer <fweimer@redhat.com> wrote:
>
>> diff --git a/iconv/gconv_db.c b/iconv/gconv_db.c
>> index 7893fadba1..b748467de5 100644
>> --- a/iconv/gconv_db.c
>> +++ b/iconv/gconv_db.c
>> @@ -179,16 +179,15 @@ free_derivation (void *p)
>> size_t cnt;
>>
>> for (cnt = 0; cnt < deriv->nsteps; ++cnt)
>> - if (deriv->steps[cnt].__counter > 0
>> - && deriv->steps[cnt].__end_fct != NULL)
>> + if ((deriv->steps[cnt].__counter > 0)
>> + && (deriv->steps[cnt].__shlib_handle != NULL))
>
> Please remove the redundant parens.
>
>> @@ -332,8 +325,7 @@ gen_steps (struct derivation_step *best, const char *toset,
>> }
>>
>> # ifdef PTR_MANGLE
>> - if (result[step_cnt].__btowc_fct != NULL)
>> - PTR_MANGLE (result[step_cnt].__btowc_fct);
>> + PTR_MANGLE (result[step_cnt].__btowc_fct);
>> # endif
>
> That needs to be mangled even if there is no init_fct.
Thanks. I'm attaching a patch to fix this. Okay?
Florian
iconv: Mangle __btowc_fct even without __init_fct [BZ #22025]
2017-08-29 Florian Weimer <fweimer@redhat.com>
[BZ #22025]
* iconv/gconv_db.c (free_derivation): Remove redundant
parentheses.
(gen_steps): Unconditionally mangle __btowc_fct after
initialization.
(increment_counter): Likewise. Do not call init_fct for internal
modules.
diff --git a/iconv/gconv_db.c b/iconv/gconv_db.c
index b748467de5..7a95aeaeac 100644
--- a/iconv/gconv_db.c
+++ b/iconv/gconv_db.c
@@ -179,8 +179,8 @@ free_derivation (void *p)
size_t cnt;
for (cnt = 0; cnt < deriv->nsteps; ++cnt)
- if ((deriv->steps[cnt].__counter > 0)
- && (deriv->steps[cnt].__shlib_handle != NULL))
+ if (deriv->steps[cnt].__counter > 0
+ && deriv->steps[cnt].__shlib_handle != NULL)
{
__gconv_end_fct end_fct = deriv->steps[cnt].__end_fct;
#ifdef PTR_DEMANGLE
@@ -323,11 +323,10 @@ gen_steps (struct derivation_step *best, const char *toset,
result[step_cnt].__end_fct = NULL;
break;
}
-
+ }
# ifdef PTR_MANGLE
- PTR_MANGLE (result[step_cnt].__btowc_fct);
+ PTR_MANGLE (result[step_cnt].__btowc_fct);
# endif
- }
}
else
#endif
@@ -403,16 +402,14 @@ increment_counter (struct __gconv_step *steps, size_t nsteps)
/* These settings can be overridden by the init function. */
step->__btowc_fct = NULL;
- }
- /* Call the init function. */
- __gconv_init_fct init_fct = step->__init_fct;
+ /* Call the init function. */
+ __gconv_init_fct init_fct = step->__init_fct;
#ifdef PTR_DEMANGLE
- PTR_DEMANGLE (init_fct);
+ PTR_DEMANGLE (init_fct);
#endif
- if (init_fct != NULL)
- {
- DL_CALL_FCT (init_fct, (step));
+ if (init_fct != NULL)
+ DL_CALL_FCT (init_fct, (step));
#ifdef PTR_MANGLE
PTR_MANGLE (step->__btowc_fct);