[PATCH] iconvdata: IBM1390/IBM1399 encoders read past input bounds (bug 34914)
Florian Weimer
fweimer@redhat.com
Fri Nov 13 10:19:01 GMT 2026
* Andreas Schwab:
> Fix a bounds check when the IBM1390 and IBM1399 encoders look up the next
> character after a combining base.
> ---
> iconvdata/Makefile | 3 ++
> iconvdata/ibm1364.c | 2 +-
> iconvdata/tst-iconv-ibm1390.c | 65 +++++++++++++++++++++++++++++++++++
> 3 files changed, 69 insertions(+), 1 deletion(-)
> create mode 100644 iconvdata/tst-iconv-ibm1390.c
>
> diff --git a/iconvdata/Makefile b/iconvdata/Makefile
> index 8d12308c94..2abafa8b0a 100644
> --- a/iconvdata/Makefile
> +++ b/iconvdata/Makefile
> @@ -89,6 +89,7 @@ tests = \
> tst-bug33980 \
> tst-e2big \
> tst-iconv-big5-hkscs-to-2ucs4 \
> + tst-iconv-ibm1390 \
> tst-iconv-iso-2022-cn-ext \
> tst-iconv4 \
> tst-iconv6 \
> @@ -356,6 +357,8 @@ $(objpfx)tst-bug33980.out: $(addprefix $(objpfx), $(gconv-modules)) \
> $(addprefix $(objpfx),$(modules.so))
> $(objpfx)tst-jisx0213-progress.out: \
> $(addprefix $(objpfx), $(gconv-modules)) $(addprefix $(objpfx),$(modules.so))
> +$(objpfx)tst-iconv-ibm1390.out: $(addprefix $(objpfx), $(gconv-modules)) \
> + $(addprefix $(objpfx),$(modules.so))
>
> $(objpfx)iconv-test.out: run-iconv-test.sh \
> $(addprefix $(objpfx), $(gconv-modules)) \
> diff --git a/iconvdata/ibm1364.c b/iconvdata/ibm1364.c
> index 8df66ea048..6c10e8e1a8 100644
> --- a/iconvdata/ibm1364.c
> +++ b/iconvdata/ibm1364.c
> @@ -286,7 +286,7 @@ enum
> while (cmbp->res1 < ch) \
> ++cmbp; \
> /* XXX if last char is beginning of combining store in state */ \
> - if (cmbp->res1 == ch && inptr + 4 < inend) \
> + if (cmbp->res1 == ch && inptr + 8 <= inend) \
Please avoid out-of-bounds pointer arithmetic, given that you are
changing this line anyway. I think the condition should be:
cmbp->res1 == ch && inend - inptr >= 8
I wonder if
/* XXX if last char is beginning of combining store in state */ \
results in a hang with the right buffer boundaries because we never mage
forward progress? Or do we just produce the wrong output?
Thanks,
Florian
More information about the Libc-alpha
mailing list