aboutsummaryrefslogtreecommitdiff
path: root/src/internal/fuzz/encoding.go
AgeCommit message (Collapse)Author
2022-09-30internal: fix a few function names on commentscui fliter
Change-Id: I53169e386b8c789b092de348fa891fe50e11c2ef GitHub-Last-Rev: 75232393b4ba415bddc731f15550d7094ccfd953 GitHub-Pull-Request: golang/go#55965 Reviewed-on: https://go-review.googlesource.com/c/go/+/436883 Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-05-20internal/fuzz: trim carriage return from version lineDan Kortschak
On windows hosts, when code is checked out using git with the default setting of autocrlf=true, carriage returns are appended to source lines which then prevent the version check from being successful. This removes carriage returns to allow version matching. Fixes #52268 Change-Id: I9acc4e907c93a20305f8742cc01687a122a88645 Reviewed-on: https://go-review.googlesource.com/c/go/+/402074 Reviewed-by: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Dan Kortschak <dan@kortschak.io> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-03-08internal/fuzz: fix encoding for out-of-range ints and runesBryan C. Mills
Also switch float64 NaN encoding to use hexadecimal, and accept hexadecimal encoding for all other integer types too. (That gives us the flexibility to change the encodings in either direction in the future without breaking earlier Go versions.) Out-of-range runes encoded using "%q" were previously replaced with the Unicode replacement charecter, losing their values. Out-of-range ints and uints on 32-bit platforms were previously rejected. Now they are wrapped instead: an “interesting” case with a large int or uint found on a 64-bit platform likely remains interesting on a 32-bit platform, even if the specific values differ. To verify the above changes, I have made TestMarshalUnmarshal accept (and check for) arbitrary differences between input and output, and added tests cases that include values in valid but non-canonical encodings. I have also added round-trip fuzz tests in the opposite direction for most of the types affected by this change, verifying that a marshaled value unmarshals to the same bitwise value. Updates #51258 Updates #51526 Fixes #51528 Change-Id: I7727a9d0582d81be0d954529545678a4374e88ed Reviewed-on: https://go-review.googlesource.com/c/go/+/390424 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-04internal/fuzz: handle Inf/NaN float valuesRoland Shoemaker
Fixes #51258 Change-Id: I3c8b785ac912d66e1a6e2179625e6903032b8330 Reviewed-on: https://go-review.googlesource.com/c/go/+/388354 Reviewed-by: Bryan Mills <bcmills@google.com> Trust: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> Auto-Submit: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-13all: gofmt -w -r 'interface{} -> any' srcRuss Cox
And then revert the bootstrap cmd directories and certain testdata. And adjust tests as needed. Not reverting the changes in std that are bootstrapped, because some of those changes would appear in API docs, and we want to use any consistently. Instead, rewrite 'any' to 'interface{}' in cmd/dist for those directories when preparing the bootstrap copy. A few files changed as a result of running gofmt -w not because of interface{} -> any but because they hadn't been updated for the new //go:build lines. Fixes #49884. Change-Id: Ie8045cba995f65bd79c694ec77a1b3d1fe01bb09 Reviewed-on: https://go-review.googlesource.com/c/go/+/368254 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-09-10[dev.fuzz] internal/fuzz: write a newline to the end of a corpus fileKatie Hockman
If someone manually adds/alters a corpus file to add extra spacing or remove the final newline, the file can still be decoded. However, this change ensures that the fuzzing engine correctly writes the final newline. Fixes golang/go#48130 Change-Id: Ib5556d4a6e4e0bfd9bc2edab357b7c25bedfd176 Reviewed-on: https://go-review.googlesource.com/c/go/+/349055 Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-04-12[dev.fuzz] internal/fuzz: allow float types to be integer literalsKatie Hockman
Previously, something like `float64(0)` would fail to decode since the 0 value is considered an integer literal, and the float64 parsing code required a float literal. Be more flexible here since an integer can always be converted to a float. Change-Id: Id1c53ef2e8a9748a4f71176b00b453a329af4ade Reviewed-on: https://go-review.googlesource.com/c/go/+/309032 Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-02-23[dev.fuzz] testing,internal/fuzz: support structured inputsKatie Hockman
This change makes several refactors to start supporting structured fuzzing. The mutator can still only mutate byte slices, and future changes will be made to support mutating other types. However, it does now support fuzzing more than one []byte. This change also makes it so that corpus entries are encoded in the new file format when being written to testdata or GOCACHE. Any existing GOCACHE data should be deleted from your local workstation to allow tests to pass locally. Change-Id: Iab8fe01a5dc870f0c53010b9d5b0b479bbdb310d Reviewed-on: https://go-review.googlesource.com/c/go/+/293810 Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-02-22[dev.fuzz] internal/fuzz: updating version incodingKatie Hockman
Based on feedback from rsc@, update the version encoding to more clearly indicate that this is about fuzzing with Go. Change-Id: Id95dec8283608779b157bf662e7147f9a9c8dba8 Reviewed-on: https://go-review.googlesource.com/c/go/+/295110 Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-02-17[dev.fuzz] internal/fuzz: support corpus file encoding/decodingKatie Hockman
Change-Id: Id245ce5f154557f1744210e7d7f061d08901c746 Reviewed-on: https://go-review.googlesource.com/c/go/+/290951 Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>