Running a 4 letter word command against zetcd causes a spike in memory usage, this applies to all but ruok.
Steps to reproduce:
echo cons | nc 127.0.0.1 2181
- Observe memory usage spike to around 2gb (depending on command, see below).
Looks like the issue is caused by
|
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.