mirror of
https://github.com/golang/go
synced 2024-11-25 07:07:57 -07:00
encoding/asn1: unmarshal bool values correctly dealing with the ANY type
Fixes #68241 Change-Id: I1ee81aa50c2f39f535ad27309e855f19acb2f2ea Reviewed-on: https://go-review.googlesource.com/c/go/+/595796 Auto-Submit: Roland Shoemaker <roland@golang.org> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Roland Shoemaker <roland@golang.org>
This commit is contained in:
parent
7d114b5b71
commit
c9ad32bd9f
@ -702,6 +702,8 @@ func parseField(v reflect.Value, bytes []byte, initOffset int, params fieldParam
|
||||
if !t.isCompound && t.class == ClassUniversal {
|
||||
innerBytes := bytes[offset : offset+t.length]
|
||||
switch t.tag {
|
||||
case TagBoolean:
|
||||
result, err = parseBool(innerBytes)
|
||||
case TagPrintableString:
|
||||
result, err = parsePrintableString(innerBytes)
|
||||
case TagNumericString:
|
||||
|
@ -311,6 +311,26 @@ func TestIssue11130(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssue68241(t *testing.T) {
|
||||
for i, want := range []any{false, true} {
|
||||
data, err := Marshal(want)
|
||||
if err != nil {
|
||||
t.Errorf("cannot Marshal: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
var got any
|
||||
_, err = Unmarshal(data, &got)
|
||||
if err != nil {
|
||||
t.Errorf("cannot Unmarshal: %v", err)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("#%d Unmarshal, got: %v, want: %v", i, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkMarshal(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user