Skip to content
This repository was archived by the owner on Oct 7, 2023. It is now read-only.
This repository was archived by the owner on Oct 7, 2023. It is now read-only.

4 letter word commands leaking memory #109

@nylar

Description

@nylar

Running a 4 letter word command against zetcd causes a spike in memory usage, this applies to all but ruok.

Steps to reproduce:

  1. echo cons | nc 127.0.0.1 2181
  2. Observe memory usage spike to around 2gb (depending on command, see below).

Looks like the issue is caused by

zetcd/encode.go

Line 244 in 8db3822

blen := int(binary.BigEndian.Uint32(buf[:4]))
where the 4 letter command is incorrectly interpreted as the length of the payload.

So in the case of cons, int(binary.BigEndian.Uint32(buf[:4])) returns 1668247155, this exceeds the capacity of the buffer so a new buffer is allocated of that size causing the large memory usage.

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