]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/commit
MFC r314686: sh: Fix crash if a -T trap is taken during command substitution.
authorjilles <jilles@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Fri, 14 Apr 2017 21:42:27 +0000 (21:42 +0000)
committerjilles <jilles@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Fri, 14 Apr 2017 21:42:27 +0000 (21:42 +0000)
commit662d0e0d84f9580b5c5f74a6503d997a097af7c9
treec1a8beacfa38020164c873fabbbe33852d3c0fcd
parent3c7ead3c64ac79cecd9c64ade2f8f4a272ef103d
MFC r314686: sh: Fix crash if a -T trap is taken during command substitution.

Code like  t=$(stat -f %m "$file")  segfaulted if -T was active and a trap
was taken while the shell was waiting for the child process to finish.

What happened was that the dotrap() call in waitforjob() was hit. This
re-entered command execution (including expand.c) at a point not expected by
expbackq(), and global state (unallocated stack string and argbackq) was
corrupted.

To fix this, change expbackq() to prepare for command execution to be
re-entered.

In stable/10, there is more global state that needs to be restored than in
stable/11 and head.

Reported by: bdrewery

git-svn-id: svn://svn.freebsd.org/base/stable/10@316942 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
bin/sh/expand.c
bin/sh/tests/expansion/Makefile
bin/sh/tests/expansion/cmdsubst21.0 [new file with mode: 0644]
bin/sh/tests/expansion/cmdsubst22.0 [new file with mode: 0644]