summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2021-06-07 22:18:05 -0700
committerdormando <dormando@rydia.net>2021-06-07 22:18:05 -0700
commit2a8b96105857dee237889f6a9e02d42352874e02 (patch)
treed84ea55bd91eaf376d4a18f76a5111e2c8268eed
parentd0b560d91a3bf7b7cda93759c48b5319e9743911 (diff)
downloadmemcached-2a8b96105857dee237889f6a9e02d42352874e02.tar.gz
meta: more realistic buffer limit for binary keys.
-rw-r--r--proto_text.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/proto_text.c b/proto_text.c
index 6e15799..67930cc 100644
--- a/proto_text.c
+++ b/proto_text.c
@@ -993,14 +993,17 @@ static int _meta_flag_preparse(token_t *tokens, const size_t ntokens,
p += 2; \
}
-// TODO: calc bytes remaining in buffer
+// NOTE: being a little casual with the write buffer.
+// the buffer needs to be sized that the longest possible meta response will
+// fit. Here we allow the key to fill up to half the write buffer, in case
+// something terrible has gone wrong.
#define META_KEY(p, key, nkey, bin) { \
META_CHAR(p, 'k'); \
if (!bin) { \
memcpy(p, key, nkey); \
p += nkey; \
} else { \
- p += base64_encode((unsigned char *) key, nkey, (unsigned char *)p, WRITE_BUFFER_SIZE); \
+ p += base64_encode((unsigned char *) key, nkey, (unsigned char *)p, WRITE_BUFFER_SIZE / 2); \
*p = ' '; \
*(p+1) = 'b'; \
p += 2; \