]> git.ipfire.org Git - thirdparty/git.git/commitdiff
gitk: sanitize 'exec' arguments: redirections and background
authorJohannes Sixt <j6t@kdbg.org>
Sat, 29 Mar 2025 16:21:27 +0000 (17:21 +0100)
committerTaylor Blau <me@ttaylorr.com>
Fri, 23 May 2025 21:03:30 +0000 (17:03 -0400)
Convert 'exec' calls that both redirect output to a file and run the
process in the background. 'safe_exec_redirect' can take both these
"redirections" in the second argument simultaneously.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
gitk

diff --git a/gitk b/gitk
index 218f61fa28f223c1eb245ea2b759edc8132ffbc5..c0d793f05dc045b45b445152c532057fd5bb979c 100755 (executable)
--- a/gitk
+++ b/gitk
@@ -9363,8 +9363,7 @@ proc mkpatchgo {} {
     set newid [$patchtop.tosha1 get]
     set fname [$patchtop.fname get]
     set cmd [diffcmd [list $oldid $newid] -p]
-    lappend cmd >$fname &
-    if {[catch {eval exec $cmd} err]} {
+    if {[catch {safe_exec_redirect $cmd [list >$fname &]} err]} {
         error_popup "[mc "Error creating patch:"] $err" $patchtop
     }
     catch {destroy $patchtop}
@@ -9553,7 +9552,7 @@ proc wrcomgo {} {
     set id [$wrcomtop.sha1 get]
     set cmd "echo $id | [$wrcomtop.cmd get]"
     set fname [$wrcomtop.fname get]
-    if {[catch {exec sh -c $cmd >$fname &} err]} {
+    if {[catch {safe_exec_redirect [list sh -c $cmd] [list >$fname &]} err]} {
         error_popup "[mc "Error writing commit:"] $err" $wrcomtop
     }
     catch {destroy $wrcomtop}