Skip to content

execve argv is not NULL-terminated #2

Description

@tv42

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,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions