[hackers] [sbase] Fix col(1) -f || sin

From: <git_AT_suckless.org>
Date: Fri, 17 Oct 2014 22:14:04 +0200

commit ff93350289a96308e73cc5d7ab1d689d08ea0efc
Author: sin <sin_AT_2f30.org>
Date: Fri Oct 17 21:12:23 2014 +0100

    Fix col(1) -f
    
    patch taken from openbsd.
    
    Ingo Schwarze says:
    
    If you call the col(1) utility with the -f option, permitting forward
    half-line feeds in the output stream, and the input stream actually
    contains half-line feeds in either direction, you end up with corrupt
    output, containing meaningless escape-digitnine sequences instead of
    the required escape-tab sequences.
    
       $ hexdump -C half.txt
      00000000 61 1b 09 62 1b 09 63 0a |a..b..c.|
      00000008
       $ col -f < half.txt | hexdump -C
      00000000 61 1b 39 0d 20 62 1b 39 0d 20 20 63 0a |a.9. b.9. c.|
      0000000d
    
    Note how the third character changes from 0x09 to 0x39.
    
    OK to commit the following fix? Don't worry, it isn't dangerous,
    it only changes two *bits*, only a quarter of a byte.
    
    The bug was introduced by the original author, Michael Rendell,
    and committed by Keith Bostic on May 22, 1990 (SCCS rev. 5.1).
    
    The following operating systems are affected:
    
     * 4.3BSD Reno, BSD Net/2, 4.4BSD, 4.4BSD Lite1, 4.4BSD Lite2
     * All versions of 386BSD, NetBSD, OpenBSD, FreeBSD and DragonFly
     * All versions of Debian GNU/Linux and probably many other Linuxes

diff --git a/col.c b/col.c
index c06f73b..e30161f 100644
--- a/col.c
+++ b/col.c
_AT_@ -346,7 +346,7 @@ flush_blanks(void)
                 PUTC('\n');
         if (half) {
                 PUTC('\033');
- PUTC('9');
+ PUTC('\011');
                 if (!nb)
                         PUTC('\r');
         }
Received on Fri Oct 17 2014 - 22:14:04 CEST

This archive was generated by hypermail 2.3.0 : Fri Oct 17 2014 - 22:24:09 CEST