]> Cypherpunks repositories - gostls13.git/commit
go/build: fix cgo ${SRCDIR} substitution when that variable contains spaces
authorDidier Spezia <didier.06@gmail.com>
Sun, 25 Oct 2015 20:18:17 +0000 (20:18 +0000)
committerRuss Cox <rsc@golang.org>
Thu, 26 Nov 2015 17:08:14 +0000 (17:08 +0000)
commit8818cc8885526b79dbe14d3bbb6f44a28435ce5c
tree54f9478f1e0bac4f04f49c47de3d8c1c02757550
parent7b767f4e521c2481e08051c843badd0382fde3b0
go/build: fix cgo ${SRCDIR} substitution when that variable contains spaces

When the source directory path contains spaces, cgo directives
cannot be properly validated:

$ pwd
/root/src/issue 11868

$ cat main.go
package main
//#cgo CFLAGS: -I${SRCDIR}/../../include
import "C"
func main() {
}

$ go build
can't load package: package issue 11868: /root/src/issue 11868/main.go:
 malformed #cgo argument: -I/root/src/issue 11868/../../include

Make sure spaces are tolerated in ${SRCDIR} when this variable
is expanded. This applies to ${SRCDIR} only. Shell safety
checks are still done in the same exact way for anything else.

Fixes #11868

Change-Id: I93d1d2b5ab167caa7ae353fe46fb8f69f1f06969
Reviewed-on: https://go-review.googlesource.com/16302
Reviewed-by: Russ Cox <rsc@golang.org>
src/go/build/build.go
src/go/build/build_test.go