You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to unmarshal a struct containing a string field fails on recent hg
checkout on 386-linux. Below is code demonstrating this:
package main
import "asn1"
import "bytes"
import "io/ioutil"
type Ok struct { A, B int }
type Fails struct { S string; A, B int }
func main() {
var ok Ok
var fails Fails
// This is ok
buf := bytes.NewBuffer(nil)
if e := asn1.Marshal(buf, Ok{0x22,0x33}); e!=nil {
panic("Marshal")
}
if _, e := asn1.Unmarshal(&ok, buf.Bytes()); e!=nil {
panic("Unmarshal")
}
// Now try it with a structure containing a string
buf = bytes.NewBuffer(nil)
if e := asn1.Marshal(buf, Fails{"foo", 0x22,0x33}); e!=nil {
panic("Marshal2")
}
// write it to a file where it can be inspected, try with:
// openssl asn1parse -inform DER -in /tmp/asn1.der
ioutil.WriteFile("/tmp/asn1.der", buf.Bytes(), 0644)
// The bug is here - this fails!
if _, e := asn1.Unmarshal(&fails, buf.Bytes()); e!=nil {
panic("Unmarshal2")
}
}
The text was updated successfully, but these errors were encountered:
Note that the marshalling won't work properly either unless the patch in issue #515 is
already aplied. It is not a bug in the marshalling patch as can be seen with dumping
the values with external tools.
The text was updated successfully, but these errors were encountered: