mirror of
https://github.com/golang/go
synced 2024-11-21 20:54:45 -07:00
cgo: Only allow numeric / string / character type constants for references
to #defined things. Fixes #520. R=rsc, rsaarelm CC=golang-dev https://golang.org/cl/186138
This commit is contained in:
parent
c6336155f1
commit
e8afb6d87f
@ -48,8 +48,14 @@ func (p *Prog) loadDebugInfo() {
|
||||
val = strings.TrimSpace(line[tabIndex:])
|
||||
}
|
||||
|
||||
// Only allow string, character, and numeric constants. Ignoring #defines for
|
||||
// symbols allows those symbols to be referenced in Go, as they will be
|
||||
// translated by gcc later.
|
||||
_, err := strconv.Atoi(string(val[0]))
|
||||
if err == nil || val[0] == '\'' || val[0] == '"' {
|
||||
defines[key] = val
|
||||
}
|
||||
}
|
||||
|
||||
// Construct a slice of unique names from p.Crefs.
|
||||
m := make(map[string]int)
|
||||
|
Loading…
Reference in New Issue
Block a user