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

4 letter word commands leaking memory #109

Open
nylar opened this issue Aug 5, 2019 · 0 comments
Open

4 letter word commands leaking memory #109

nylar opened this issue Aug 5, 2019 · 0 comments

Comments

@nylar
Copy link

nylar commented Aug 5, 2019

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant