Skip to content

Out of memory when Decode is passed certain invalid data #11

@jakobvarmose

Description

@jakobvarmose

When the data contains a large string length as in the example below, decodeString tries to allocate all of this memory upfront so the program crashes.

package main

import (
	"bytes"
	"fmt"

	"github.com/jackpal/bencode-go"
)

func main() {
	data := []byte("99999999999:")
	buf := bytes.NewBuffer(data)
	res, err := bencode.Decode(buf)
	fmt.Println(res, err)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions