Skip to content

encoding/pem: can't decode encoded message #10980

Closed
@dvyukov

Description

encoding/pem successfully decodes a message in the following program; but if the message is re-encoded, decoding fails:

package main

import "encoding/pem"

func main() {
    data := []byte("-----BEGIN foo-----\n\n-----END foo-----")
    b, _ := pem.Decode(data)
    if b == nil {
        return
    }
    enc := pem.EncodeToMemory(b)
    b1, _ := pem.Decode(enc)
    if b1 == nil {
        panic("can't decode encoded")
    }
}

Either the first Decode should fail, or the second Decode should succeed.

on commit 6551803

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions