RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1222867 - zsh in ksh emulation mode, coredumps when trying to check the syntax of a shell script
Summary: zsh in ksh emulation mode, coredumps when trying to check the syntax of a she...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: zsh
Version: 7.0
Hardware: x86_64
OS: Linux
urgent
urgent
Target Milestone: rc
: ---
Assignee: Kamil Dudka
QA Contact: Jan Kepler
URL:
Whiteboard:
Depends On:
Blocks: 1274697
TreeView+ depends on / blocked
 
Reported: 2015-05-19 10:28 UTC by Tim Speetjens
Modified: 2019-08-15 04:36 UTC (History)
5 users (show)

Fixed In Version: zsh-5.0.2-11.el7
Doc Type: Bug Fix
Doc Text:
Previously, the code that initializes environment variables in zsh did not correctly handle NULL values. As a consequence, zsh terminated unexpectedly when attempting to check the syntax of a shell script in ksh emulation mode. This update fixes the handling of NULL values, and the syntax check now works as expected when zsh runs in ksh emulation mode.
Clone Of:
: 1274697 (view as bug list)
Environment:
Last Closed: 2015-11-19 05:20:32 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:2208 0 normal SHIPPED_LIVE zsh bug fix and enhancement update 2015-11-19 08:16:54 UTC

Description Tim Speetjens 2015-05-19 10:28:43 UTC
Description of problem:
zsh in ksh emulation mode, coredumps when trying to check the syntax of a shell script

Version-Release number of selected component (if applicable):
RHEL7:
zsh-5.0.2-7.el7.x86_64

Fedora21:
zsh-5.0.7-7.fc21.x86_64

How reproducible:
100%

Steps to Reproduce:

1 Create test script:
$ cat <<EOF > test
#!/usr/bin/ksh
echo test
EOF

2 Test syntax
$ ksh -n test

Actual results:
zsh coredumps

Expected results:
exit cleanly, with code 0 or 1, depending on validity of the given script

Additional info:

$ which ksh
/usr/bin/ksh

$ ls -l ksh
lrwxrwxrwx. 1 root root 3 May 19 11:55 ksh -> zsh

On RHEL7 (zsh-5.0.2-7.el7.x86_64)
Core was generated by `ksh -n test'.
Program terminated with signal 11, Segmentation fault.
#0  mkenvstr (name=0x20fcdf0 "HOME", value=0x0, flags=flags@entry=4198400) at params.c:4496
4496		 *s && (*s++ != Meta || *s++ != 32); len_value++);
(gdb) bt
#0  mkenvstr (name=0x20fcdf0 "HOME", value=0x0, flags=flags@entry=4198400) at params.c:4496
#1  0x000000000046312e in createparamtable () at params.c:741
#2  0x000000000043e71f in setupvals () at init.c:987
#3  0x000000000044060c in zsh_main (argc=<optimized out>, argv=<optimized out>) at init.c:1596
#4  0x00007fe7d4056af5 in __libc_start_main (main=0x40eca0 <main>, argc=3, ubp_av=0x7fff92db4098, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, 
    stack_end=0x7fff92db4088) at libc-start.c:274
#5  0x000000000040ecd1 in _start ()
(gdb) 

Running the same check with zsh runs fine

Comment 2 Kamil Dudka 2015-05-19 18:15:24 UTC
Thank you for reporting the bug!

The following patch fixes the problem for me:

--- a/Src/params.c
+++ b/Src/params.c
@@ -4574,22 +4574,24 @@ addenv(Param pm, char *value)


 /* Given strings *name = "foo", *value = "bar", *
  * return a new string *str = "foo=bar".        */

 /**/
 static char *
 mkenvstr(char *name, char *value, int flags)
 {
     char *str, *s;
     int len_name, len_value;
+    if (!value)
+       return NULL;

     len_name = strlen(name);
     for (len_value = 0, s = value;
         *s && (*s++ != Meta || *s++ != 32); len_value++);
     s = str = (char *) zalloc(len_name + len_value + 2);
     strcpy(s, name);
     s += len_name;
     *s = '=';
     copyenvstr(s, value, flags);
     return str;
 }

I will check with upstream whether it is a correct way to fix it.

Comment 3 Kamil Dudka 2015-05-20 17:36:33 UTC
upstream commit:

http://sourceforge.net/p/zsh/code/ci/af957f2e

Comment 7 Kamil Dudka 2015-05-22 14:49:38 UTC
fixed in zsh-5.0.7-8.fc2{0,1,2,3}

Comment 8 Kamil Dudka 2015-09-29 13:14:34 UTC
*** Bug 1267251 has been marked as a duplicate of this bug. ***

Comment 13 errata-xmlrpc 2015-11-19 05:20:32 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://rhn.redhat.com/errata/RHBA-2015-2208.html


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