Bug 1299484 - Multibyte character string after $1-9 in ksh is not expanded correctly.
Summary: Multibyte character string after $1-9 in ksh is not expanded correctly.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: ksh
Version: 7.2
Hardware: All
OS: All
medium
low
Target Milestone: rc
: ---
Assignee: Siteshwar Vashisht
QA Contact: Jan Kepler
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-01-18 13:37 UTC by Martin Kyral
Modified: 2017-08-01 16:26 UTC (History)
3 users (show)

Fixed In Version: ksh-20120801-34.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1256495
Environment:
Last Closed: 2017-08-01 16:26:55 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2017:1936 0 normal SHIPPED_LIVE ksh bug fix update 2017-08-01 17:55:48 UTC

Description Martin Kyral 2016-01-18 13:37:18 UTC
The same bug is in ksh-20120801-22.el7_1.3

+++ This bug was initially created as a clone of Bug #1256495 +++

This problem has been reported upstream at
http://lists.research.att.com/pipermail/ast-users/2015q3/004775.html

"""
 Hi,

  I have this test case from a user, where ksh changed behavior
from ksh-20100621 to ksh-20120801.

  The test case is these 2 files:

$ cat test1.sh
#!/bin/ksh
echo "$1テスト"
echo "${1}テスト"
echo "$1test"

and

$ cat test2.sh
#!/bin/ksh
echo "$1テスト" | od -x
echo "${1}テスト" | od -x
echo "$1test" | od -x

  They output:
$ ksh ./test1.sh
�スト
テスト
test
$ ksh ./test2.sh
0000000 e386 b982 83e3 0a88
0000010
0000000 83e3 e386 b982 83e3 0a88
0000012
0000000 6574 7473 000a
0000005

  Previously ksh, in src/cmd/ksh93/sh/macro.c:varsub()
was:

    c = fcget();
    if(type>M_TREE)
...
    nulflg = 0;
    if(type && c==':')
...
    if(type)
...
    else
    {
        fcseek(-1);
        c=0;
    }
    if(c==':')  /* ${name:expr1[:expr2]} */

  The code in newer ksh is almost identical, with the
exception that instead of "c = fcget();" it starts with:

    c = fcmbget(&LEN);

that causes it to read 3 characters, but only "backtrack"
one character in the given test case.

  The attached patch corrects the problem, should be
simple enough, and only use the previous behavior when
the condition in the test case is met.

Thanks,
Paulo
"""

Comment 6 errata-xmlrpc 2017-08-01 16:26:55 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:1936


Note You need to log in before you can comment on or make changes to this bug.