Bug 104286 - coreutils-5.3.0-i18n-0.1.patch breaks expand
Bug#: 104286 Product:  Gentoo Linux Version: unspecified Platform: All
OS/Version: Linux Status: RESOLVED Severity: blocker Priority: P2
Resolution: FIXED Assigned To: base-system@gentoo.org Reported By: gentoo.bugzilla@peteru.dnsalias.net
Component: Core system
URL:  http://openi18n.org/cgi-bin/bugzilla/show_bug.cgi?id=103
Summary: coreutils-5.3.0-i18n-0.1.patch breaks expand
Keywords:  
Status Whiteboard: 
Opened: 2005-08-30 11:19 0000
Description:   Opened: 2005-08-30 11:19 0000
generic/000_all_coreutils-i18n.patch in coreutils-5.3.0 breaks expand in such a
way that expand does not work properly when LANG="C" and it encounters a blank line.

Simple test:

$ echo | LANG="en_AU.UTF-8" expand

$ echo | LANG="C" expand
expand: input line is too long

This is caused by the following part of the patch:

@@ -352,7 +372,8 @@ expand (void)
                }
              else
                {
-                 column++;
+                 if (!ISCNTRL (c))
+                   column++;
                  if (!column)
                    error (EXIT_FAILURE, 0, _("input line is too long"));
                }

Furthermore, this failure is masked by generic/009_all_coreutils-tests.patch
which explicitly disables expand test and comments on the fact that it fails in
this manner.

This makes the expand command almost completely useless and can cause nasty
failures. For example, glibc build failure.


Reproducible: Always
Steps to Reproduce:

------- Comment #1 From peteru 2005-08-30 11:57:40 0000 -------
This patch appears to fix the problem.

Rather than relying on integer overflow to indicate that a line is too long,
this code checks that column index has not reached the maximum signed value of
the variable. I decided to use the signed limit as opposed to unsigned limit
(the variable itself is unsigned) because the number is sufficiently large
enough and there is no risk of sign errors due to inadvertent casts.

diff -u expand.c expand.c~
--- expand.c    2005-08-31 04:47:34.000000000 +1000
+++ expand.c~   2005-08-31 03:30:54.000000000 +1000
@@ -374,7 +374,7 @@
                {
                  if (!ISCNTRL (c))
                    column++;
-                 if (!column)
+                 if (column >= INTMAX_MAX)
                    error (EXIT_FAILURE, 0, _("input line is too long"));
                }


------- Comment #2 From SpanKY 2005-08-30 16:31:56 0000 -------
or better yet, use the coreutils define UINTMAX_MAX

------- Comment #3 From SpanKY 2005-08-30 16:53:14 0000 -------
fixed in coreutils-5.3.0-r1, thanks