]> git.ipfire.org Git - thirdparty/glibc.git/commit
gconv: Do not emit spurious NUL character in ISO-2022-JP-3 (bug 28524)
authorNikita Popov <npv1310@gmail.com>
Tue, 2 Nov 2021 08:21:42 +0000 (13:21 +0500)
committerAurelien Jarno <aurelien@aurel32.net>
Sat, 4 Dec 2021 23:29:46 +0000 (00:29 +0100)
commit5abb1c32c22145c9e01307910fa2f82adf85d3ee
tree59c9c7e566d059f7fd3419c189eb6cb53bee1ad7
parentb923e061d4986e6c73f882698f65c911596fae5e
gconv: Do not emit spurious NUL character in ISO-2022-JP-3 (bug 28524)

Bugfix 27256 has introduced another issue:
In conversion from ISO-2022-JP-3 encoding, it is possible
to force iconv to emit extra NUL character on internal state reset.
To do this, it is sufficient to feed iconv with escape sequence
which switches active character set.
The simplified check 'data->__statep->__count != ASCII_set'
introduced by the aforementioned bugfix picks that case and
behaves as if '\0' character has been queued thus emitting it.

To eliminate this issue, these steps are taken:
* Restore original condition
'(data->__statep->__count & ~7) != ASCII_set'.
It is necessary since bits 0-2 may contain
number of buffered input characters.
* Check that queued character is not NUL.
Similar step is taken for main conversion loop.

Bundled test case follows following logic:
* Try to convert ISO-2022-JP-3 escape sequence
switching active character set
* Reset internal state by providing NULL as input buffer
* Ensure that nothing has been converted.

Signed-off-by: Nikita Popov <npv1310@gmail.com>
(cherry picked from commit ff012870b2c02a62598c04daa1e54632e020fd7d)
NEWS
iconvdata/Makefile
iconvdata/bug-iconv15.c [new file with mode: 0644]
iconvdata/iso-2022-jp-3.c