summaryrefslogtreecommitdiff
path: root/src/encoding/asn1
diff options
context:
space:
mode:
authorkaxapi <kashimov@gmail.com>2019-10-14 10:12:05 +0000
committerBrad Fitzpatrick <bradfitz@golang.org>2019-11-08 18:28:44 +0000
commit4692343cf401a5bbcc290d48fead12157754b8e5 (patch)
tree0ea6183be3c390172992a45eee853baacc73a2fa /src/encoding/asn1
parentaff3aaa47f16d69efc50b6fec0ddc938176695eb (diff)
downloadgo-git-4692343cf401a5bbcc290d48fead12157754b8e5.tar.gz
encoding/asn1: fix unmarshalling SEQUENCE OF SET
Fixes #27426 Change-Id: I34d4784658ce7b9e6130bae9717e80d0e9a290a2 GitHub-Last-Rev: 6de610cdcef11832f131b84a0338b68af16b10da GitHub-Pull-Request: golang/go#30059 Reviewed-on: https://go-review.googlesource.com/c/go/+/160819 Reviewed-by: Agniva De Sarker <agniva.quicksilver@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
Diffstat (limited to 'src/encoding/asn1')
-rw-r--r--src/encoding/asn1/asn1_test.go19
-rw-r--r--src/encoding/asn1/common.go3
2 files changed, 22 insertions, 0 deletions
diff --git a/src/encoding/asn1/asn1_test.go b/src/encoding/asn1/asn1_test.go
index d5649bff9f..5cadf31510 100644
--- a/src/encoding/asn1/asn1_test.go
+++ b/src/encoding/asn1/asn1_test.go
@@ -1129,3 +1129,22 @@ func TestBMPString(t *testing.T) {
}
}
}
+
+func TestSequenceOfSet(t *testing.T) {
+ type someSetSET struct {
+ A int `asn1:"tag:0"`
+ }
+
+ type someStruct struct {
+ B int `asn1:"tag:0"`
+ C []someSetSET `asn1:"tag:1"`
+ }
+
+ der := []byte{0x30, 0x0F, 0x80, 0x01, 0x01, 0xA1, 0x0A, 0x31, 0x03, 0x80, 0x01, 0x01, 0x31, 0x03, 0x80, 0x01, 0x02}
+
+ var b someStruct
+ if _, err := Unmarshal(der, &b); err != nil {
+ t.Errorf("Unmarshal failed: %v", err)
+ }
+
+}
diff --git a/src/encoding/asn1/common.go b/src/encoding/asn1/common.go
index e2aa8bd9c5..b0ca1c8aab 100644
--- a/src/encoding/asn1/common.go
+++ b/src/encoding/asn1/common.go
@@ -167,6 +167,9 @@ func getUniversalType(t reflect.Type) (matchAny bool, tagNumber int, isCompound,
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return false, TagInteger, false, true
case reflect.Struct:
+ if strings.HasSuffix(t.Name(), "SET") {
+ return false, TagSet, true, true
+ }
return false, TagSequence, true, true
case reflect.Slice:
if t.Elem().Kind() == reflect.Uint8 {