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: Unmarshal allows arbitrary numbers of leading zeros when decoding integers #12622

Closed
alex opened this issue Sep 15, 2015 · 2 comments
Closed
Assignees
Milestone

Comments

@alex
Copy link
Contributor

@alex alex commented Sep 15, 2015

Example:

package main

import (
    "encoding/asn1"
    "fmt"
    "math/big"
)

func main() {
    data := &struct {
        A int64
        B *big.Int
    }{}
    _, err := asn1.Unmarshal([]byte{0x30, 0x0e, 0x02, 0x05, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x05, 0x00, 0x00, 0x00, 0x00, 0x01}, data)
    if err != nil {
        panic(err)
    }
    fmt.Printf("%#v\n", data)
}

Per the DER spec, INTEGER must be minimally encoded.

$ go version
go version go1.5.1 darwin/amd64
@bradfitz bradfitz added this to the Go1.6 milestone Sep 15, 2015
@gopherbot
Copy link

@gopherbot gopherbot commented Nov 16, 2015

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

@gopherbot
Copy link

@gopherbot gopherbot commented Nov 18, 2015

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

@bradfitz bradfitz closed this in 7c20ea9 Dec 1, 2015
@golang golang locked and limited conversation to collaborators Dec 1, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.