Skip to content
Myr

completion(zsh): use private mktemp dir for completion FIFO

Before adoption: this commit came in with the history the project adopted, so no landing records it.

FIFO path was predictable (${TMPDIR:-/tmp}/fzf-complete-fifo-$$) and _fzf_feed_fifo ignored rm/mkfifo failures, so on a shared /tmp another user could pre-create the path (symlink or FIFO) and have the victim's redirect follow it. Allocate the FIFO inside a per-invocation mktemp -d directory, check mkfifo status, and clean up the directory instead of the bare path.

authored by Junegunn Choi · committed by Junegunn Choi · parent f126ff2 · Browse files · 2 files+7 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Reported-by: sb24CK (https://github.com/sb24CK)

Diff stats

2 files+7 added−4 removed

  • other:+7 added−4 removed

2 files+7 added−4 removed

modified:shell/completion.zsh+5 added-4 removed
213 unmodified lines
214}215216_fzf_feed_fifo() {217 command rm -f "$1"218 mkfifo "$1"218 command mkfifo "$1" || return219 cat <&0 > "$1" &|220}221222_fzf_complete() {
18 unmodified lines
241 shift242 rest=("$@")243 fi244245 local fifo lbuf matches post246 fifo="${TMPDIR:-/tmp}/fzf-complete-fifo-$$"245 local fifo fifo_dir lbuf matches post246 fifo_dir=$(command mktemp -d "${TMPDIR:-/tmp}/fzf-completion-XXXXXX") || return247 fifo="$fifo_dir/fifo"248 lbuf=${rest[0]}249 post="${funcstack[1]}_post"250 type $post > /dev/null 2>&1 || post=cat251
4 unmodified lines
256 __fzf_comprun "$cmd_word" "${args[@]}" -q "${(Q)prefix}" < "$fifo" | $post | tr '\n' ' ')257 if [ -n "$matches" ]; then258 LBUFFER="$lbuf$matches"259 fi259 command rm -f "$fifo"260 command rm -rf "$fifo_dir"261}262263# To use custom hostname lists, override __fzf_list_hosts.264# The function is expected to print hostnames, one per line as well as in the
213 unmodified lines
modified:CHANGELOG.md+2 added
11 unmodified lines
12- Fixed `--popup` unzooming the window when opened over a zoomed pane on tmux 3.8 or above (#4927, junegunn/fzf.vim#1625)13 - On tmux 3.7, the window is still unzoomed, as tmux 3.7b crashes when a floating pane is created over a zoomed window14- Security fixes15 - fzf-tmux no longer evaluates an attached layout size (e.g. `-l50`) via bash arithmetic, which could run commands or inject tmux flags (GHSA-w6x2-f5m4-xw82)16 - zsh completion now creates its FIFO in a private `mktemp -d` directory instead of a predictable `/tmp` path (GHSA-7rj6-7pqx-v7rm)17 - Reported by Sai Sreewathsa Kovalluri, Shon Babu, and Kannan K (Researchers) of Innspark Solutions18190.74.420------21- Fixed an escape sequence split across reads being parsed as a fragment, which leaked the rest into the query (#4899)
3451 unmodified lines