[PATCH] Fix cli socket close due to io buffer full

Kenth Eriksson kenth.eriksson at infinera.com
Mon Jun 10 17:00:07 CEST 2019


Bird io module will close any socket when it reads zero bytes from it. The
cli module has some logic error causing the buffer pointer rpos to be
positioned at end of buffer. The result of that is that the io module will
request to receive zero bytes from the socket.

The pointer rpos in the socket io module is only restored if the rx_hook
callback returns 1. Previously the cli_rx hook always returned 0. Guarantee by
design that we return 1 if we are at the end of the socket buffer.

It is possible that this fix should be applied inside the cli_get_command
instead. The problem happens there as the pointer in the while loop may
be incremented outside io buffer.

Signed-off-by: Kenth Eriksson <kenth.eriksson at infinera.com>
---
 sysdep/unix/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sysdep/unix/main.c b/sysdep/unix/main.c
index 921115b1..68179d6c 100644
--- a/sysdep/unix/main.c
+++ b/sysdep/unix/main.c
@@ -419,7 +419,7 @@ static int
 cli_rx(sock *s, uint size UNUSED)
 {
   cli_kick(s->data);
-  return 0;
+  return s->rbuf+s->rbsize==s->rpos? 1 : 0;
 }
 
 static void
-- 
2.21.0



More information about the Bird-users mailing list