Skip to content

Commit

Permalink
meta: more realistic buffer limit for binary keys.
Browse files Browse the repository at this point in the history
  • Loading branch information
dormando committed Jun 8, 2021
1 parent d0b560d commit 2a8b961
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions proto_text.c
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
Expand Down

0 comments on commit 2a8b961

Please sign in to comment.