google / flatbuffers

FlatBuffers: Memory Efficient Serialization Library
https://flatbuffers.dev/
Apache License 2.0
22.56k stars 3.19k forks source link

[Golang] Add bounds-checked decoding functions #8244

Open ricardonunez-io opened 4 months ago

ricardonunez-io commented 4 months ago

"Safe"-prepended "Get" decoding functions in the Go package include bounds checking to avoid panics for situations where safety from untrusted inputs is critical and performance isn't as necessary.

Does not modify existing functions, simply adds 15 new functions for each type of decoding available in go/encode.go.

Does not include safety measures for decoding strings.

jdemeyer commented 3 months ago

How is one supposed to use these functions? Ideally these would be used in safe variants of the generated code.

Also, there is clearly some functional overlap with https://github.com/google/flatbuffers/pull/8030