Browse Source

Fix off-by-one error in bkey send size and clear buffer properly in clear_bufline

master
Con Kolivas 9 years ago
parent
commit
4a64775a86
  1. 3
      src/ckpool.c
  2. 4
      src/connector.c

3
src/ckpool.c

@ -579,6 +579,7 @@ static void clear_bufline(connsock_t *cs)
if (unlikely(!cs->buf)) {
socklen_t optlen = sizeof(cs->rcvbufsiz);
cs->bufofs = 0;
cs->buf = ckzalloc(PAGESIZE);
cs->bufsize = PAGESIZE;
getsockopt(cs->fd, SOL_SOCKET, SO_RCVBUF, &cs->rcvbufsiz, &optlen);
@ -589,8 +590,8 @@ static void clear_bufline(connsock_t *cs)
memset(cs->buf + cs->buflen, 0, cs->bufofs);
cs->bufofs = cs->buflen;
cs->buflen = 0;
cs->buf[cs->bufofs] = '\0';
}
cs->buf[cs->bufofs] = '\0';
}
static void add_buflen(ckpool_t *ckp, connsock_t *cs, const char *readbuf, const int len)

4
src/connector.c

@ -1272,8 +1272,10 @@ static void process_client_msg(cdata_t *cdata, char *buf, uint32_t msglen)
msg = json_dumps(json_msg, JSON_EOL | JSON_COMPACT);
slen = strlen(msg);
if (blen) {
msglen = slen + blen;
/* We're overwriting the EOL so remove it from msglen */
msglen = slen + blen - 1;
msg = realloc(msg, msglen);
/* Overwrite the EOL here */
memcpy(msg + slen - 1, bkey, blen);
send_client(cdata, client_id, msg, slen, msglen);
} else

Loading…
Cancel
Save