mrosset / vte

simple go language bindings to vte
3 stars 3 forks source link

execve argv is not NULL-terminated #2

Open tv42 opened 9 years ago

tv42 commented 9 years ago

man execve says Both argv and envp must be terminated by a NULL pointer.. With the current code, that does not happen, and this can be observed with strace -ff -e execve ./myterminal.

diff --git i/vte.go w/vte.go
index 4f972e5..5009acd 100644
--- i/vte.go
+++ w/vte.go
@@ -85,12 +85,13 @@ func (v *Terminal) Feed(m string) {
 }

 func (v *Terminal) Fork(args []string) {
-       cargs := C.make_strings(C.int(len(args)))
+       cargs := C.make_strings(C.int(len(args) + 1))
        for i, j := range args {
                ptr := C.CString(j)
                defer C.free(unsafe.Pointer(ptr))
                C.set_string(cargs, C.int(i), ptr)
        }
+       C.set_string(cargs, C.int(len(args)), nil)
        C.vte_terminal_fork_command_full(v.Native(),
                C.VTE_PTY_DEFAULT,
                nil,
mrosset commented 9 years ago

Thanks for the issue, will get this updated along with some go-gtk fixs this weekend.