summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Nault <g.nault@alphalink.fr>2016-04-27 21:02:37 +0200
committerDmitry Kozlov <xeb@mail.ru>2016-04-28 11:16:05 +0300
commit16449c4f4972ffad500951db5c71403cae0422e7 (patch)
treea7987a14e41bd5cceac9e82a7fa990b31015e257
parent7de0d2d00be552dede15dfd02c9e423dda7eb6f5 (diff)
downloadaccel-ppp-16449c4f4972ffad500951db5c71403cae0422e7.tar.gz
accel-ppp-16449c4f4972ffad500951db5c71403cae0422e7.zip
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 <g.nault@alphalink.fr>
-rw-r--r--accel-pppd/cli/tcp.c2
-rw-r--r--accel-pppd/cli/telnet.c2
2 files changed, 2 insertions, 2 deletions
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);