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 accepts negative dates #11134

Closed
dvyukov opened this issue Jun 9, 2015 · 1 comment
Closed

encoding/asn1: Unmarshal accepts negative dates #11134

dvyukov opened this issue Jun 9, 2015 · 1 comment
Milestone

Comments

@dvyukov
Copy link
Member

dvyukov commented Jun 9, 2015

The following program:

package main

import (
    "encoding/asn1"
    "time"
    "fmt"
)

func main() {
    data := []byte("\x18\x0f00000100000000Z")
    var v time.Time
    _, err := asn1.Unmarshal(data, &v)
    if err != nil {
        return
    }
    fmt.Printf("%v\n",v)
    _, err = asn1.Marshal(v)
    if err != nil {
        panic(err)
    }
}

panics with:

-0001-12-31 00:00:00 +0000 UTC
panic: asn1: structure error: cannot represent time as GeneralizedTime

The value is successfully unmarshalled, but can't be marshalled. I am not sure who exactly is wrong here. This happens because of "date normalization" in time package, it converts day 0 to the last day of the previous month. ASN.1 (ISO 8601) does not define "date normalization", if I understand correctly, assuming that dates and times are valid as is.

I think we should not do time/date normalization, because it is asking for troubles security-wise.

@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Jun 10, 2015
@gopherbot
Copy link

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

@agl agl closed this as completed in fdd921c 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
@rsc rsc unassigned agl Jun 23, 2022
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

5 participants