Skip to content

bufio: ReadBytes nead a limit maybe #8105

@gopherbot

Description

@gopherbot

by golangwink:

for {
        var e error
        frag, e = b.ReadSlice(delim)
        if e == nil { // got final fragment
            break
        }
        if e != ErrBufferFull { // unexpected error
            err = e
            break
        }

        // Make a copy of the buffer.
        buf := make([]byte, len(frag))
        copy(buf, frag)
        full = append(full, buf) // if full is too big?
    }

The bufio.ReadBytes don't have a limit to append, it isn't a problem when use if for
files, but when you use bufio.ReadBytes for net socket, the client may never give you
the correct delimiter.

Then the memory of server will use up by even if only a connection.

thank you for your attention!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions