]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: work around FreeBSD execve kernel bug
authorDevon H. O'Dell <devon.odell@gmail.com>
Sun, 6 Mar 2011 19:57:05 +0000 (14:57 -0500)
committerRuss Cox <rsc@golang.org>
Sun, 6 Mar 2011 19:57:05 +0000 (14:57 -0500)
FreeBSD's execve implementation has an integer underflow in a bounds test which
causes it to erroneously think the argument list is too long when argv[0] is
longer than interpreter + path.

R=rsc, bradfitz, rsc1
CC=golang-dev
https://golang.org/cl/4259056

src/pkg/syscall/exec_unix.go

index 04c066918f8941569ddfeef6455024ce76ebff34..2e09539eeae345b389814e686c4f50d5d6ea6dba 100644 (file)
@@ -238,6 +238,10 @@ func forkExec(argv0 string, argv []string, envv []string, traceme bool, dir stri
                dirp = StringBytePtr(dir)
        }
 
+       if OS == "freebsd" && len(argv[0]) > len(argv0) {
+               argvp[0] = argv0p
+       }
+
        // Acquire the fork lock so that no other threads
        // create new fds that are not yet close-on-exec
        // before we fork.