From 72b21d0537b49f23254bdf63ad9a3d1a61b3bbbe Mon Sep 17 00:00:00 2001 From: Guillaume Nault Date: Wed, 27 Apr 2016 21:02:39 +0200 Subject: 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 --- 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 9061edd1..3a00cfec 100644 --- a/accel-pppd/cli/tcp.c +++ b/accel-pppd/cli/tcp.c @@ -95,7 +95,7 @@ static int cli_client_send(struct cli_client_t *tcln, 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); 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); -- cgit v1.2.3