summaryrefslogtreecommitdiff
path: root/accel-pppd/cli/telnet.c
diff options
context:
space:
mode:
authorGuillaume Nault <g.nault@alphalink.fr>2016-04-27 21:02:39 +0200
committerDmitry Kozlov <xeb@mail.ru>2016-04-28 11:16:47 +0300
commit72b21d0537b49f23254bdf63ad9a3d1a61b3bbbe (patch)
tree95b6fc1a967d3ec8263163bcbebb3651b63611cf /accel-pppd/cli/telnet.c
parent16449c4f4972ffad500951db5c71403cae0422e7 (diff)
downloadaccel-ppp-72b21d0537b49f23254bdf63ad9a3d1a61b3bbbe.tar.gz
accel-ppp-72b21d0537b49f23254bdf63ad9a3d1a61b3bbbe.zip
cli: fix data output miss-ordering
In tcp and telnet backends, the first buffer been queued is directly pointed to by cln->xmit_buf. It's not added to cln->xmit_queue. Therefore testing if ->xmit_queue is empty doesn't reliably tells if data has already been queued. We should test if ->xmit_buf is non-NULL instead. This is reliable because ->xmit_buf is re-filled with the first buffer from ->xmit_queue after every successful write(). Failure to properly check if data has already been queued can lead to message miss-ordering because cli_client_send() or telnet_send() will try to directly write() their input buffer, effectively bypassing the one previously queued up in ->xmit_buf. Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Diffstat (limited to 'accel-pppd/cli/telnet.c')
-rw-r--r--accel-pppd/cli/telnet.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/accel-pppd/cli/telnet.c b/accel-pppd/cli/telnet.c
index b8ca8231..6c41769e 100644
--- a/accel-pppd/cli/telnet.c
+++ b/accel-pppd/cli/telnet.c
@@ -143,7 +143,7 @@ static int telnet_send(struct telnet_client_t *cln, const void *_buf, int size)
if (cln->disconnect)
return -1;
- if (!list_empty(&cln->xmit_queue)) {
+ if (cln->xmit_buf) {
b = _malloc(sizeof(*b) + size);
b->size = size;
memcpy(b->buf, buf, size);