Skip to content

Commit 2aeb448

Browse files
j6tttaylorr
authored andcommitted
gitk: sanitize 'open' arguments: simple commands, readable and writable
As in the previous commits, introduce a function that sanitizes arguments and also keeps the returned file handle writable to pass data to stdin. Signed-off-by: Johannes Sixt <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent 42a64b4 commit 2aeb448

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

gitk

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ proc safe_open_command {cmd} {
6666
open |[make_arglist_safe $cmd] r
6767
}
6868

69+
# opens a command pipeline for reading and writing
70+
# cmd is a list that specifies the command and its arguments
71+
# calls `open` and returns the file id
72+
proc safe_open_command_rw {cmd} {
73+
open |[make_arglist_safe $cmd] r+
74+
}
75+
6976
# opens a command pipeline for reading with redirections
7077
# cmd is a list that specifies the command and its arguments
7178
# redir is a list that specifies redirections
@@ -4897,8 +4904,8 @@ proc do_file_hl {serial} {
48974904
# must be "containing:", i.e. we're searching commit info
48984905
return
48994906
}
4900-
set cmd [concat | git diff-tree -r -s --stdin $gdtargs]
4901-
set filehighlight [open $cmd r+]
4907+
set cmd [concat git diff-tree -r -s --stdin $gdtargs]
4908+
set filehighlight [safe_open_command_rw $cmd]
49024909
fconfigure $filehighlight -blocking 0
49034910
filerun $filehighlight readfhighlight
49044911
set fhl_list {}

0 commit comments

Comments
 (0)