sh: Fix INTOFF leak when a redirection on a compound command fails.

Reported by:	bdrewery
This commit is contained in:
Jilles Tjoelker
2017-06-04 20:52:55 +00:00
parent 51d93426d9
commit eab4998278
3 changed files with 7 additions and 0 deletions
+1
View File
@@ -470,6 +470,7 @@ evalredir(union node *n, int flags)
if (e == EXERROR || e == EXEXEC) { if (e == EXERROR || e == EXEXEC) {
if (in_redirect) { if (in_redirect) {
exitstatus = 2; exitstatus = 2;
FORCEINTON;
return; return;
} }
} }
+1
View File
@@ -29,6 +29,7 @@ ${PACKAGE}FILES+= redirection-error4.0
${PACKAGE}FILES+= redirection-error5.0 ${PACKAGE}FILES+= redirection-error5.0
${PACKAGE}FILES+= redirection-error6.0 ${PACKAGE}FILES+= redirection-error6.0
${PACKAGE}FILES+= redirection-error7.0 ${PACKAGE}FILES+= redirection-error7.0
${PACKAGE}FILES+= redirection-error8.0
${PACKAGE}FILES+= write-error1.0 ${PACKAGE}FILES+= write-error1.0
.include <bsd.test.mk> .include <bsd.test.mk>
+5
View File
@@ -0,0 +1,5 @@
# $FreeBSD$
$SH -c '{ { :; } </var/empty/x; } 2>/dev/null || kill -INT $$; echo continued'
r=$?
[ "$r" -gt 128 ] && [ "$(kill -l "$r")" = INT ]