[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
trap RETURN not set in calling function is overwritten by callee
From: |
jtmoon+bashbug |
Subject: |
trap RETURN not set in calling function is overwritten by callee |
Date: |
Tue, 18 Aug 2015 23:48:52 -0700 (PDT) |
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL
-DHAVE_CONFIG_H -I. -I../. -I.././include -I.././lib -D_FORTIFY_SOURCE=2 -g
-O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat
-Werror=format-security -Wall
uname output: Linux moonrock 3.13.0-48-generic #80-Ubuntu SMP Thu Mar 12
11:16:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 4.3
Patch Level: 11
Release Status: release
Description:
Given two functions wherein only one function sets a RETURN trap. The
other
function will mistakenly call the other's RETURN trap upon it's return.
Repeat-By:
# test trap RETURN if unset from called function
function testU1() {
function _testU1_ret() { echo "${FUNCNAME}" ; }
trap _testU1_ret RETURN
}
function testU2() {
testU1
# when testU2 returns, will it call _testU1_ret ?
}
testU2
# prints the following
_testU1_ret
_testU1_ret
Fix:
For some reason the RETURN traps are not being stacked. Instead, the
current RETURN trap is just overwritten.
- trap RETURN not set in calling function is overwritten by callee,
jtmoon+bashbug <=