From 16449c4f4972ffad500951db5c71403cae0422e7 Mon Sep 17 00:00:00 2001 From: Guillaume Nault Date: Wed, 27 Apr 2016 21:02:37 +0200 Subject: cli: fix partial line duplication and truncation When queueing output data for later write(), the 'n' first bytes of the buffer have already been sent (we have n > 0 if EAGAIN was returned after some other write() calls succeeded). Therefore, we need to skip these bytes when initialising the buffer to be queued. The size passed to memcpy() did already take that space into account. Signed-off-by: Guillaume Nault --- accel-pppd/cli/tcp.c | 2 +- accel-pppd/cli/telnet.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'accel-pppd/cli') diff --git a/accel-pppd/cli/tcp.c b/accel-pppd/cli/tcp.c index 2a6bfdee..9061edd1 100644 --- a/accel-pppd/cli/tcp.c +++ b/accel-pppd/cli/tcp.c @@ -109,7 +109,7 @@ static int cli_client_send(struct cli_client_t *tcln, const void *_buf, int size if (errno == EAGAIN) { b = _malloc(sizeof(*b) + size - n); b->size = size - n; - memcpy(b->buf, buf, size - n); + memcpy(b->buf, buf + n, size - n); queue_buffer(cln, b); triton_md_enable_handler(&cln->hnd, MD_MODE_WRITE); diff --git a/accel-pppd/cli/telnet.c b/accel-pppd/cli/telnet.c index de2f39ff..b8ca8231 100644 --- a/accel-pppd/cli/telnet.c +++ b/accel-pppd/cli/telnet.c @@ -157,7 +157,7 @@ static int telnet_send(struct telnet_client_t *cln, const void *_buf, int size) if (errno == EAGAIN) { b = _malloc(sizeof(*b) + size - n); b->size = size - n; - memcpy(b->buf, buf, size - n); + memcpy(b->buf, buf + n, size - n); queue_buffer(cln, b); triton_md_enable_handler(&cln->hnd, MD_MODE_WRITE); -- cgit v1.2.3