2022-01-23 14:38:41 +03:00
|
|
|
// tool to convert go fuzz input files to bytes
|
2022-12-04 11:41:55 +03:00
|
|
|
// Usage: cat format/testdata/fuzz/FuzzFormats/144bde49b40c90fd05d302ec90b6ddb2b6d6aea553bad520a8b954797e40fe72 | go run dev/fuzzbytes.go | go run .
|
2022-01-23 14:38:41 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
2022-08-05 01:20:14 +03:00
|
|
|
"io"
|
2022-01-23 14:38:41 +03:00
|
|
|
"os"
|
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2022-08-05 01:20:14 +03:00
|
|
|
bs, err := io.ReadAll(os.Stdin)
|
2022-01-23 14:38:41 +03:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Input looks like this:
|
|
|
|
// go test fuzz v1
|
|
|
|
// []byte("...")
|
|
|
|
prefix := []byte("[]byte(")
|
|
|
|
start := bytes.Index(bs, prefix) + len(prefix)
|
|
|
|
end := len(bs) - 2
|
|
|
|
s, err := strconv.Unquote(string(bs[start:end]))
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := os.Stdout.Write([]byte(s)); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|