Package: sed
Version: 4.2.1-3
Severity: critical
Justification: breaks unrelated software
With locale environment set to zh_CN.GBK, the installation of package
console-setup version 1.45 will be stuck due to the failure of sed to
process string like following (excerpt from console-setup.config):
zh_CN*variant*ma*french*Morocco - 法语
The last 2 Chinese characters are encoded in UTF-8, with byte sequence
that would be imcomplete for GBK.
While sed tries to decode those bytes into local encoding with a call to
mbrtowc(3), it ignored the possibility of incomplete multibyte sequence,
thus an endless loop.
A simple patch is available in the attachment.
And as a workaround to console-setup, the locale could be set to C to
bypass the sed problem.
Regards
-- System Information:
Debian Release: squeeze/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.30-1-686 (SMP w/2 CPU cores)
Locale: LANG=zh_CN.UTF-8, LC_CTYPE=zh_CN.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages sed depends on:
ii libc6 2.9-25 GNU C Library: Shared libraries
ii libselinux1 2.0.85-3 SELinux shared libraries
sed recommends no packages.
sed suggests no packages.
-- no debconf information
diff -urN sed-4.2.1/sed/execute.c sed-4.2.1.new/sed/execute.c
--- sed-4.2.1/sed/execute.c 2009-06-26 18:13:53.000000000 +0800
+++ sed-4.2.1.new/sed/execute.c 2009-10-15 18:43:18.000000000 +0800
@@ -254,8 +254,8 @@
{
size_t n = MBRLEN (string, length, &to->mbstate);
- /* An invalid sequence is treated like a singlebyte character. */
- if (n == (size_t) -1)
+ /* An invalid or imcomplete sequence is treated like a singlebyte character. */
+ if (n == (size_t) -1 || n == (size_t) -2)
{
memset (&to->mbstate, 0, sizeof (to->mbstate));
n = 1;