The vulnerability occurs because the 'go' command did not properly sanitize directory names containing newline characters when cgo is used. This could lead to parts of the directory path being injected as code during the cgo processing step, specifically when '#line' or '//line' directives are generated.
The patch addresses this in two main places:
- In
src/cmd/go/internal/load/pkg.go, a check is added to explicitly disallow package directory paths (p.Dir) containing newline characters. The function responsible for loading package details would have been the entry point for the malicious path.
- In
src/cmd/go/internal/work/exec.go, a check is added to ensure that if a package has an error (p.Error is not nil, which would now be set by the aforementioned check), the build process for that package is halted. This prevents the invocation of cgo with an invalid path.
The vulnerable functions are those that, prior to the patch, would have processed these newline-containing paths and passed them along to the cgo processing stages, or failed to stop the build process when such a path was encountered. The names are inferred based on common Go practices and the context in the diff, as exact function signatures are not always present in diffs alone. The confidence is 'medium' because the exact function names are inferred from the context of the file and typical Go program structure rather than being explicitly stated in the diff for the modified code blocks themselves.