summaryrefslogtreecommitdiff
path: root/proto_bin.c
diff options
context:
space:
mode:
authorTomas Korbar <tkorbar@redhat.com>2022-01-28 18:08:13 +0100
committerdormando <dormando@rydia.net>2022-02-09 12:54:04 -0800
commit4df826aafdd6abf0fc483d52774047c3533206dc (patch)
treedb43cdc7ff29ef8689285c722b308014c6a25cdb /proto_bin.c
parentcbb8efb4dd1c4d3c9a9f4dcfe82d6f9f28005df9 (diff)
downloadmemcached-4df826aafdd6abf0fc483d52774047c3533206dc.tar.gz
Extend extbuf in try_read_command_binary function
Extbuf needs to have 48 bytes because it is used for protocol_binary_request_incr union. Unions member message is alligned to 48 bytes.
Diffstat (limited to 'proto_bin.c')
-rw-r--r--proto_bin.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/proto_bin.c b/proto_bin.c
index b61c3bb..d8b37c5 100644
--- a/proto_bin.c
+++ b/proto_bin.c
@@ -110,7 +110,10 @@ int try_read_command_binary(conn *c) {
// want to refactor a ton of code either. Header is only ever used out
// of c->binary_header, but the extlen stuff is used for the latter
// bytes. Just wastes 24 bytes on the stack this way.
- char extbuf[sizeof(c->binary_header) + BIN_MAX_EXTLEN+1];
+
+ // +4 need to be here because extbuf is used for protocol_binary_request_incr
+ // and its member message is alligned to 48 bytes intead of 44
+ char extbuf[sizeof(c->binary_header) + BIN_MAX_EXTLEN+4];
memcpy(extbuf + sizeof(c->binary_header), c->rcurr + sizeof(c->binary_header),
extlen > BIN_MAX_EXTLEN ? BIN_MAX_EXTLEN : extlen);
c->rbytes -= sizeof(c->binary_header) + extlen + keylen;