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: Marshal rejects encoding *T even if T is encodeable #50578

Open
mcy opened this issue Jan 12, 2022 · 1 comment
Open

encoding/asn1: Marshal rejects encoding *T even if T is encodeable #50578

mcy opened this issue Jan 12, 2022 · 1 comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@mcy
Copy link

mcy commented Jan 12, 2022

https://go.dev/play/p/Aj7m_EiK1EX

package main

import (
	"encoding/asn1"
	"fmt"
)

func main() {
	b, e := asn1.Marshal(struct{}{})
	fmt.Printf("%x, %s\n", b, e)
	b, e = asn1.Marshal(&struct{}{})
	fmt.Printf("%x, %s\n", b, e)
}

What did you expect to see?

Equal values for both prints.

What did you see instead?

3000, %!s(<nil>)
, asn1: structure error: unknown Go type: *struct {}

Ideally, Marshal (and arguably Unmarshal) should recurse through pointers as they do interfaces. Of course, encoding/asn1 is... not really the best ASN.1 library, so maybe we should put a comment on it saying to use crypto/cryptobytes and call it a day.

@mcy mcy changed the title encoding/asn1: Marshal rejects encoding T* even if T is encodeable encoding/asn1: Marshal rejects encoding *T even if T is encodeable Jan 12, 2022
@dr2chase dr2chase added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 13, 2022
@dr2chase
Copy link
Contributor

@FiloSottile @katiehockman either of you have an opinion on this?

@seankhliao seankhliao added this to the Unplanned milestone Aug 20, 2022
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

3 participants