Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/asn1: better error message when unmarshaling non-pointer #15370

Open
phayes opened this issue Apr 19, 2016 · 2 comments
Open

encoding/asn1: better error message when unmarshaling non-pointer #15370

phayes opened this issue Apr 19, 2016 · 2 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@phayes
Copy link

phayes commented Apr 19, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    NaCL / Playground
  2. What operating system and processor architecture are you using (go env)?
    Playground
  3. What did you do?
    https://play.golang.org/p/TnLoso9len
  4. What did you expect to see?
1.2.840.113549.1.9.16.1.4
[6 11 42 134 72 134 247 13 1 9 16 1 4]
1.2.840.113549.1.9.16.1.4
  1. What did you see instead?
1.2.840.113549.1.9.16.1.4
[6 11 42 134 72 134 247 13 1 9 16 1 4]
panic: reflect: call of reflect.Value.Elem on slice Value

goroutine 1 [running]:
panic(0x184720, 0x10434260)
    /usr/local/go/src/runtime/panic.go:464 +0x700
reflect.Value.Elem(0x188f40, 0x10434250, 0x97, 0x10434250, 0x0, 0x0, 0x0, 0x188f40)
    /usr/local/go/src/reflect/value.go:735 +0x2a0
encoding/asn1.UnmarshalWithParams(0x10444074, 0xd, 0x40, 0x188f40, 0x10434250, 0x0, 0x0, 0x10434220, 0x0, 0x0, ...)
    /usr/local/go/src/encoding/asn1/asn1.go:989 +0xc0
encoding/asn1.Unmarshal(0x10444074, 0xd, 0x40, 0x188f40, 0x10434250, 0x10434250, 0x0, 0x0, 0x0, 0x0, ...)
    /usr/local/go/src/encoding/asn1/asn1.go:983 +0x80
main.main()
    /tmp/sandbox412831617/main.go:24 +0x480
@martisch
Copy link
Contributor

martisch commented Apr 19, 2016

not a bug in asn1.go.

in https://play.golang.org/p/TnLoso9len

_, err = asn1.Unmarshal(data, oid) 

needs to be

_, err = asn1.Unmarshal(data, &oid)

"uses the reflect package to fill in an arbitrary value pointed at by val"
The pointed at is important.

But maybe it is warranted to add a check and write out a better error.

@phayes
Copy link
Author

phayes commented Apr 19, 2016

Gah! That's embarrassing! Let me change the title to reflect this.

@phayes phayes changed the title encoding/asn1: panic when marshaling then unmarshaling asn1.ObjectIdentifier encoding/asn1: better error message when unmarshaling non-pointer Apr 19, 2016
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Apr 19, 2016
@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants