mirror of
https://github.com/golang/go
synced 2024-11-23 10:10:02 -07:00
encoding/asn1: document what Unmarshal returns in rest
Specifically, this change documents the behavior of Unmarshal when a SEQUENCE contains trailing elements. For context Unmarshal treats trailing elements of a SEQUENCE that do not have matching struct fields as valid, as this is how ASN.1 structures are typically extended. This can be somewhat confusing as you might expect those elements to be appended to rest, but rest is really only for trailing data unrelated to the structure being parsed (i.e. if you append a second sequence to b, it would be returned in rest). Fixes #35680 Change-Id: Ia2c68b2f7d8674d09e859b4b7f9aff327da26fa0 Reviewed-on: https://go-review.googlesource.com/c/go/+/233537 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Katie Hockman <katie@golang.org>
This commit is contained in:
parent
9acdc705e7
commit
b68fa57c59
@ -1037,6 +1037,12 @@ func setDefaultValue(v reflect.Value, params fieldParameters) (ok bool) {
|
||||
// Because Unmarshal uses the reflect package, the structs
|
||||
// being written to must use upper case field names.
|
||||
//
|
||||
// After parsing b, any bytes that were leftover and not used to fill
|
||||
// val will be returned in rest. When parsing a SEQUENCE into a struct,
|
||||
// any trailing elements of the SEQUENCE that do not have matching
|
||||
// fields in val will not be included in rest, as these are considered
|
||||
// valid elements of the SEQUENCE and not trailing data.
|
||||
//
|
||||
// An ASN.1 INTEGER can be written to an int, int32, int64,
|
||||
// or *big.Int (from the math/big package).
|
||||
// If the encoded value does not fit in the Go type,
|
||||
|
Loading…
Reference in New Issue
Block a user