mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-09 12:11:20 -03:00
use mktemp(1) to generate temporary file names
Fix for CVE-2014-2906. Closes a race condition in funced which would allow execution of arbitrary code; closes a race condition in psub which would allow alternation of the data stream. Note that `psub -f` does not work (#1040); a fix should be committed separately for ease of maintenance. Closes #1437
This commit is contained in:
@@ -81,11 +81,7 @@ function funced --description 'Edit function definition'
|
||||
return 0
|
||||
end
|
||||
|
||||
set -q TMPDIR; or set -l TMPDIR /tmp
|
||||
set -l tmpname (printf "$TMPDIR/fish_funced_%d_%d.fish" %self (random))
|
||||
while test -f $tmpname
|
||||
set tmpname (printf "$TMPDIR/fish_funced_%d_%d.fish" %self (random))
|
||||
end
|
||||
set tmpname (mktemp -t fish_funced.XXXXXXXXXX)
|
||||
|
||||
if functions -q -- $funcname
|
||||
functions -- $funcname > $tmpname
|
||||
|
||||
Reference in New Issue
Block a user