Browse Source

Fix off-by-one error in parsing bkeys in parse_client_msg

master
Con Kolivas 9 years ago
parent
commit
4f637a8be5
  1. 10
      src/connector.c

10
src/connector.c

@ -528,7 +528,7 @@ reparse:
blen = bkey_len(bkey); blen = bkey_len(bkey);
if (len < blen) if (len < blen)
goto retry; goto retry;
buflen = slen + blen; buflen = slen + blen + 1;
} else } else
buflen = eol - client->buf + 1; buflen = eol - client->buf + 1;
@ -538,7 +538,6 @@ reparse:
invalidate_client(ckp, cdata, client); invalidate_client(ckp, cdata, client);
return; return;
} }
if (!(val = json_loads(client->buf, JSON_DISABLE_EOF_CHECK, NULL))) { if (!(val = json_loads(client->buf, JSON_DISABLE_EOF_CHECK, NULL))) {
char *buf = strdup("Invalid JSON, disconnecting\n"); char *buf = strdup("Invalid JSON, disconnecting\n");
@ -549,8 +548,10 @@ reparse:
} else { } else {
char *s; char *s;
if (unlikely(blen)) if (unlikely(blen)) {
json_append_bkeys(val, bkey, blen); json_append_bkeys(val, bkey, blen);
blen = 0;
}
if (client->passthrough) { if (client->passthrough) {
int64_t passthrough_id; int64_t passthrough_id;
@ -580,7 +581,8 @@ reparse:
json_decref(val); json_decref(val);
} }
client->bufofs -= buflen; client->bufofs -= buflen;
memmove(client->buf, client->buf + buflen, client->bufofs); if (client->bufofs)
memmove(client->buf, client->buf + buflen, client->bufofs);
client->buf[client->bufofs] = '\0'; client->buf[client->bufofs] = '\0';
if (client->bufofs) if (client->bufofs)

Loading…
Cancel
Save