summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevon H. O'Dell <devon.odell@gmail.com>2011-03-06 14:57:05 -0500
committerDevon H. O'Dell <devon.odell@gmail.com>2011-03-06 14:57:05 -0500
commita0644fa55813ec6a0d5cd6178ee5ea4c70755040 (patch)
treebf858d50519ff25c1c01b93109480341184961b5
parent864d09bbb43f7088eba152a527f548f4951a5e7f (diff)
downloadgo-a0644fa55813ec6a0d5cd6178ee5ea4c70755040.tar.gz
syscall: work around FreeBSD execve kernel bug
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 http://codereview.appspot.com/4259056 Committer: Russ Cox <rsc@golang.org>
-rw-r--r--src/pkg/syscall/exec_unix.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/pkg/syscall/exec_unix.go b/src/pkg/syscall/exec_unix.go
index 04c066918..2e09539ee 100644
--- a/src/pkg/syscall/exec_unix.go
+++ b/src/pkg/syscall/exec_unix.go
@@ -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.