On Thu, Feb 24, 2011 at 11:43:44AM +0000, Alexey Gladkov wrote:
> Starting with commit 55c46b dash removes CTLESC bytes ('\x81')
> from read sequence. This leads to breakage of some UTF8
> characters. Like in commit f8231a, this change fixes corruption
> by removing the faulty code.

Thanks for the diagnosis and patch!

Unfortunately we can't just delete the rmescaps call since we do
use CTLESC to represent backslash characters in the input stream
which prevents field splitting.

So the correct fix is to add extra CTLESCs wherever CTLESC appears
in the input.  The following patch should fix the problem.

commit 54413164e587dd2dc5d7bce0bd3fab61d7ba758c
Author: Herbert Xu <herb...@gondor.apana.org.au>
Date:   Thu Mar 10 20:59:46 2011 +0800

    [BUILTIN] Fix CTLESC clobbering by read(1)
    
    The changeset 55c46b7286f5d9f2d8291158203e2b61d2494420
    
        [BUILTIN] Honor tab as IFS whitespace when splitting fields in readcmd
    
    uses CTLESC to prevent field splitting in read(1).  However,
    it did not escape CTLESC itself in the input stream.  This patch
    adds the necessary CTLESC characters so that CTLESC isn't corrupted.
    
    Reported-by: Alexey Gladkov <gladkov.ale...@gmail.com>
    Signed-off-by: Herbert Xu <herb...@gondor.apana.org.au>

diff --git a/ChangeLog b/ChangeLog
index 173f057..6d02fa9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-03-10  Herbert Xu <herb...@gondor.apana.org.au>
+
+       * Fix CTLESC clobbering by read(1).
+
 2011-03-10  Brian Koropoff <bkorop...@gmail.com>
 
        * Port to AIX.
diff --git a/src/miscbltin.c b/src/miscbltin.c
index 653c92f..800cbbb 100644
--- a/src/miscbltin.c
+++ b/src/miscbltin.c
@@ -178,7 +178,7 @@ readcmd(int argc, char **argv)
                }
                if (c == '\0')
                        continue;
-               if (backslash) {
+               if (backslash || c == CTLESC) {
                        if (c == '\n')
                                goto resetbs;
                        STPUTC(CTLESC, p);

Cheers,
-- 
Email: Herbert Xu <herb...@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to