]> Cypherpunks repositories - gostls13.git/commit
cmd/go: fuzz test splitPkgConfigOutput and fix minor bugs
authorBryan C. Mills <bcmills@google.com>
Thu, 9 Feb 2023 21:35:04 +0000 (16:35 -0500)
committerGopher Robot <gobot@golang.org>
Wed, 15 Feb 2023 15:30:05 +0000 (15:30 +0000)
commit30151f2aac2882dcb369019acfec95d16fea3c02
tree150b83da9703f48cbbb2a5b8da2ff4b3ad8799ae
parenta7b75972f267aac5607b16b0e9826d56386a92af
cmd/go: fuzz test splitPkgConfigOutput and fix minor bugs

In reviewing CL 466875, I noticed that the implementation of
splitPkgConfigOutput from CL 86541 referred to another specific
implementation, and that implementation has had recent changes to fix
deviations from the POSIX specification for shell argument parsing.

Curious about those changes, I decided to fuzz the function to check
whether it agreed in practice with the way a real shell parses
arguments in POSIX mode. It turned out to deviate in several edge
cases, such as backslash-escapes within single quotes, quoted empty
strings, and carriage returns. (We do not expect to see carriage
returns in pkg-config output anyway, but the quote handling might
matter.)

This change updates the implementation to refer to the POSIX
documentation instead of another implementation, and confirms the
behavior with a fuzz test. It may introduce minor deviations from the
pkgconf implementation that was previously used as a reference, but if
so it is plausible that those could be fixed upstream in pkgconf
(like the other recent changes there).

For #35262.
Updates ##23373.

Change-Id: Ifab76e94af0ca9a6d826379f4a6e2028561e615c
Reviewed-on: https://go-review.googlesource.com/c/go/+/466864
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
src/cmd/go/internal/work/build_test.go
src/cmd/go/internal/work/exec.go
src/cmd/go/internal/work/shell_test.go [new file with mode: 0644]