Skip to content

Invalid map is successfully decoded #34

Closed
@dvyukov

Description

@dvyukov

The following program crashes with the panic:

package main

import (
    pb "github.com/dvyukov/go-fuzz/examples/protobuf/pb"
    "github.com/golang/protobuf/proto"
)

func main() {
    data := []byte("\n\x02\n\x00")
    v := new(pb.M24)
    err := proto.Unmarshal(data, v)
    if err != nil {
        return
    }
    _, err = proto.Marshal(v)
    if err != nil {
        panic(err)
    }
}
panic: proto: map has nil element

The proto used is:

message M24 {
  map<string, M2> f = 1;
}

The message should either be successfully encoded or not decoded.

on commit 34a5f24

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions