diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-10-23 19:31:04 +0000 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-10-24 11:23:23 +0200 |
commit | 9073a4b28fc5839893981924b61c0b4ae5f96a86 (patch) | |
tree | 3d78adc72905659f0c5b6c195afeaad54267d92c | |
parent | mod: bump (diff) | |
download | wireguard-windows-9073a4b28fc5839893981924b61c0b4ae5f96a86.tar.xz wireguard-windows-9073a4b28fc5839893981924b61c0b4ae5f96a86.zip |
elevate: do not invoke shell execute if program is empty
-rw-r--r-- | elevate/shellexecute.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/elevate/shellexecute.go b/elevate/shellexecute.go index 8e238f08..6290b4f8 100644 --- a/elevate/shellexecute.go +++ b/elevate/shellexecute.go @@ -42,7 +42,7 @@ func ShellExecute(program string, arguments string, directory string, show int32 } defer func() { - if err != nil { + if err != nil && program16 != nil { err = windows.ShellExecute(0, windows.StringToUTF16Ptr("runas"), program16, arguments16, directory16, show) } }() @@ -132,6 +132,10 @@ func ShellExecute(program string, arguments string, directory string, show int32 defer syscall.Syscall((*interfacePointer)[releaseOffset], 1, uintptr(unsafe.Pointer(interfacePointer)), 0, 0) + if program16 == nil { + return + } + if ret, _, _ := syscall.Syscall6((*interfacePointer)[shellExecuteOffset], 6, uintptr(unsafe.Pointer(interfacePointer)), uintptr(unsafe.Pointer(program16)), |