Skip to content

Commit 67a128b

Browse files
j6tttaylorr
authored andcommitted
gitk: sanitize 'open' arguments: revisit recently updated 'open' calls
The previous commits bb5cb23 (gitk: prevent overly long command lines, 2023-01-24) rewrote a set of the 'open' calls substantially. These were then later updated by 7dd272e (gitk: escape file paths before piping to git log, 2023-01-24) and d5d1b91e5327 (gitk: encode arguments correctly with "open", 2025-03-07). In the preceding merge, the conversions to a safe_open variant were undone to ensure that the principal operation of the new 'open' calls is not modified by accident. Since the 'open' calls now pass a redirection from a Tcl string as stdin, convert the calls to 'safe_open_command_redirect'. Signed-off-by: Johannes Sixt <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent d7bc50c commit 67a128b

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

gitk

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,9 @@ proc start_rev_list {view} {
498498
}
499499

500500
if {[catch {
501-
set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \
502-
--parents --boundary $args --stdin \
503-
[list "<<[join [concat $revs "--" $files] "\n"]"]] r]
501+
set fd [safe_open_command_redirect [concat git log --no-color -z --pretty=raw $show_notes \
502+
--parents --boundary $args --stdin] \
503+
[list "<<[join [concat $revs "--" $files] "\n"]"]]
504504
} err]} {
505505
error_popup "[mc "Error executing git log:"] $err"
506506
return 0
@@ -651,9 +651,9 @@ proc updatecommits {} {
651651
set args $vorigargs($view)
652652
}
653653
if {[catch {
654-
set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \
655-
--parents --boundary $args --stdin \
656-
[list "<<[join [concat $revs "--" $vfilelimit($view)] "\n"]"]] r]
654+
set fd [safe_open_command_redirect [concat git log --no-color -z --pretty=raw $show_notes \
655+
--parents --boundary $args --stdin] \
656+
[list "<<[join [concat $revs "--" $vfilelimit($view)] "\n"]"]]
657657
} err]} {
658658
error_popup "[mc "Error executing git log:"] $err"
659659
return
@@ -10322,10 +10322,11 @@ proc getallcommits {} {
1032210322
if {$ids ne {}} {
1032310323
if {$ids eq "--all"} {
1032410324
set cmd [concat $cmd "--all"]
10325+
set fd [safe_open_command $cmd]
1032510326
} else {
10326-
set cmd [concat $cmd --stdin [list "<<[join $ids "\n"]"]]
10327+
set cmd [concat $cmd --stdin]
10328+
set fd [safe_open_command_redirect $cmd [list "<<[join $ids "\n"]"]]
1032710329
}
10328-
set fd [open $cmd r]
1032910330
fconfigure $fd -blocking 0
1033010331
incr allcommits
1033110332
nowbusy allcommits

0 commit comments

Comments
 (0)