Bug 1438045 - ksh -R reference script corrupted output
Summary: ksh -R reference script corrupted output
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: ksh
Version: 7.3
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Siteshwar Vashisht
QA Contact: Jan Kepler
URL:
Whiteboard:
Depends On:
Blocks: 1420851 1438459 1441142 1465901 1466365 1473612
TreeView+ depends on / blocked
 
Reported: 2017-03-31 17:50 UTC by Paulo Andrade
Modified: 2021-06-10 12:08 UTC (History)
1 user (show)

Fixed In Version: ksh-20120801-36.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1438459 1441142 1540988 (view as bug list)
Environment:
Last Closed: 2018-04-10 13:51:41 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2018:0801 0 None None None 2018-04-10 13:52:22 UTC

Description Paulo Andrade 2017-03-31 17:50:08 UTC
Test case is very simple:

 cat x.sh 
#!/bin/sh

[[ $A -lt $B ]]
[[ $A -lt $B ]]

$ ksh -R foo x.sh
x.sh: warning: line 3: -lt within [[...]] obsolete, use ((...))
x.sh: warning: line 4: -lt within [[...]] obsolete, use ((...))
$ grep obsolete foo
-5iIEV;v;Bsh: warning: line 4: -lt within [[...]] obsolete, use ((...))
1HFhH7;v;Bsh: warning: line 3: -lt within [[...]] obsolete, use ((...))

patch is also very simple:
diff -up ksh-20120801/src/cmd/ksh93/sh/parse.c.orig ksh-20120801/src/cmd/ksh93/sh/parse.c
--- ksh-20120801/src/cmd/ksh93/sh/parse.c.orig	2017-03-31 14:39:37.920062158 -0300
+++ ksh-20120801/src/cmd/ksh93/sh/parse.c	2017-03-31 14:40:14.200175096 -0300
@@ -2032,6 +2032,7 @@ unsigned long kiaentity(Lex_t *lexp,cons
 		else
 			sfputr(stkp,name,0);
 	}
+	sfputc(stkp,'\0');
 	np = nv_search(stakptr(offset),lexp->entity_tree,NV_ADD);
 	stkseek(stkp,offset);
 	np->nvalue.i = pkind;

The problem happens due to mixed usage of length based strings and
"C" (zero ended) strings. And from observation it only happens
after errors are reported. The patch just makes it work with
either string kind.

Comment 4 Siteshwar Vashisht 2017-07-14 10:52:26 UTC
https://github.com/att/ast/pull/58

Comment 10 errata-xmlrpc 2018-04-10 13:51:41 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-2018:0801


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