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: incorrectly handles incorrect utf8 strings #11126

Closed
dvyukov opened this issue Jun 9, 2015 · 2 comments
Closed

encoding/asn1: incorrectly handles incorrect utf8 strings #11126

dvyukov opened this issue Jun 9, 2015 · 2 comments
Milestone

Comments

@dvyukov
Copy link
Member

@dvyukov dvyukov commented Jun 9, 2015

The following program crashes with "Marshal: asn1: string not valid UTF-8" panic:

package main

import "encoding/asn1"

func main() {
    data := []byte("0\x05\f\x03a\xc9c")
    v := X{}
    _, err := asn1.Unmarshal(data, &v)
    if err != nil {
        panic("Unmarshal: " + err.Error())
    }
    _, err = asn1.Marshal(v)
    if err != nil {
        panic("Marshal: " + err.Error())
    }
}

type X struct {
    S string //`asn1:"utf8"`
}

The string must either be not decoded successfully or encoded successfully.

If the utf8 tag is uncommented, then program finishes successfully. This also looks wrong as the string is not valid utf8.

on commit b0532a9

@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Jun 9, 2015
@agl
Copy link
Contributor

@agl agl commented Jun 13, 2015

Thanks for that. Fix is at https://go-review.googlesource.com/11056 although I think I'll leave it until after 1.5. It's a little risky.

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 13, 2015

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

@agl agl closed this in 0a6df4a Jun 29, 2015
@mikioh mikioh modified the milestones: Go1.5, Go1.6 Jun 29, 2015
@golang golang locked and limited conversation to collaborators Jun 28, 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
5 participants
You can’t perform that action at this time.