bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sed bug: ASCII NUL doesn't work on the rhs of y// commands


From: Paolo Bonzini
Subject: Re: sed bug: ASCII NUL doesn't work on the rhs of y// commands
Date: Wed, 03 Sep 2014 13:19:33 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0

Il 03/09/2014 03:09, address@hidden ha scritto:
> Hi,
> 
> The subject pretty much says it all for this bug. Compare the output of
> "echo abc | sed -e 's/b/\x00/' | hexdump -c" and "echo abc | sed -e
> 'y/b/\x00/' | hexdump -c". The s command behaves correctly (as I would
> expect, it replaces the 'b' with a NUL character), while the y command
> fails to output anything when it should print NUL, resulting in an
> output file shorter than the input was.

Looks like the bug was introduced when "y" was extended to support
multibyte characters.  The minimal patch should be to change

         int trans_len = strlen(trans[2*i+1]);

to

         char *trans = trans[2*i+1];
         int trans_len = *trans == '\0' ? 1 : strlen(trans);

in sed/execute.c

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]