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 doesn't respect application tag #20488

Closed
hirochachacha opened this issue May 24, 2017 · 1 comment
Closed

encoding/asn1: Marshal doesn't respect application tag #20488

hirochachacha opened this issue May 24, 2017 · 1 comment
Milestone

Comments

@hirochachacha
Copy link
Contributor

Please answer these questions before submitting your issue. Thanks!

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

package main

import (
	"encoding/asn1"
	"fmt"
)

type Foo struct {
	Bar int `asn1:"application,tag:0"`
	Baz int `asn1:"application,tag:1,explicit"`
}

func main() {
	bs, err := asn1.Marshal(Foo{Bar: 1, Baz: 2})
	if err != nil {
		panic(err)
	}

	var foo Foo
	rest, err := asn1.Unmarshal(bs, &foo)
	if err != nil {
		panic(err)
	}
	if len(rest) != 0 {
		panic("rest is not empty")
	}
	fmt.Printf("%v\n", foo)
}

What did you expect to see?

{1 2}

What did you see instead?

panic: asn1: structure error: tags don't match (0 vs {class:2 tag:0 length:1 isCompound:false}) {optional:false explicit:false application:true defaultValue:<nil> tag:0xc420016160 stringType:0 timeType:0 set:false omitEmpty:false} int @2

goroutine 1 [running]:
main.main()
	/Users/hiro/o.go:22 +0x20d
exit status 2

Does this issue reproduce with the latest release (go1.8.3)?

I think so.

System details

go version devel +e0e4891827 Wed May 24 21:56:48 2017 +0000 darwin/amd64
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/hiro/.go"
GORACE=""
GOROOT="/Users/hiro/go"
GOTOOLDIR="/Users/hiro/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build434465536=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOROOT/bin/go version: go version devel +e0e4891827 Wed May 24 21:56:48 2017 +0000 darwin/amd64
GOROOT/bin/go tool compile -V: compile version devel +e0e4891827 Wed May 24 21:56:48 2017 +0000 X:framepointer
uname -v: Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64
ProductName:	Mac OS X
ProductVersion:	10.12.5
BuildVersion:	16F73
lldb --version: lldb-370.0.42
  Swift-3.1
gdb --version: GNU gdb (GDB) 7.12.1
@gopherbot
Copy link
Contributor

CL https://golang.org/cl/44110 mentions this issue.

@bradfitz bradfitz added this to the Go1.10 milestone May 24, 2017
@golang golang locked and limited conversation to collaborators Aug 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants