gitk: sanitize 'open' arguments: revisit recently updated 'open' calls
The previous commits bb5cb23daf75 (gitk: prevent overly long command lines, 2023-01-24) rewrote a set of the 'open' calls substantially. These were then later updated by 7dd272eca153 (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 <j6t@kdbg.org> Signed-off-by: Taylor Blau <me@ttaylorr.com>
Johannes Sixt committed
Mar 29, 2025 at 18:49 UTC
67a128b91e25978a15f9f7e194d81b441d603652
1 file changed
+9
-8
gitk
+9
-8
@@ -498,9 +498,9 @@ proc start_rev_list {view} {
498
}
499
500
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"]"]]
504
} err]} {
505
error_popup "[mc "Error executing git log:"] $err"
506
return 0
@@ -651,9 +651,9 @@ proc updatecommits {} {
651
set args $vorigargs($view)
652
}
653
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"]"]]
657
} err]} {
658
error_popup "[mc "Error executing git log:"] $err"
659
return
@@ -10322,10 +10322,11 @@ proc getallcommits {} {
10322
if {$ids ne {}} {
10323
if {$ids eq "--all"} {
10324
set cmd [concat $cmd "--all"]
10325
+ set fd [safe_open_command $cmd]
10326
} 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"]"]]
10329
}
10328
- set fd [open $cmd r]
10330
fconfigure $fd -blocking 0
10331
incr allcommits
10332
nowbusy allcommits