From dbf64764581577d35ee988f2987804a4803a1edd Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Wed, 2 Oct 2024 23:37:14 +0200 Subject: [PATCH] Flock: fixed some random bugs but there are obviously some more --- flock/container.c | 6 ++++++ flock/hypervisor.c | 14 +++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/flock/container.c b/flock/container.c index 8868eefc7..44e1ea6ff 100644 --- a/flock/container.c +++ b/flock/container.c @@ -459,6 +459,12 @@ container_mainloop(int fd) exit(1); } + if (sz == 0) + { + log(L_INFO "control socket closing, shutdown"); + exit(0); + } + ASSERT_DIE(sz >= 3); ASSERT_DIE(buf[0] == 0xa1); switch (buf[1]) { diff --git a/flock/hypervisor.c b/flock/hypervisor.c index 8513b0802..37e3d6e54 100644 --- a/flock/hypervisor.c +++ b/flock/hypervisor.c @@ -40,15 +40,15 @@ hcs_rx(sock *s, uint size) log(L_INFO "Parsed command."); /* TODO do something more */ + if (sz < size) + memmove(s->rbuf, s->rbuf + sz, size - sz); + if (!s->rx_hook) + return (sz == size); hcs_parser_cleanup(s->data); s->data = hcs_parser_init(s); - if (sz == size) - return 1; - - memmove(s->rbuf, s->rbuf + sz, size - sz); - return hcs_rx(s, size - sz); + return (sz < size) ? hcs_rx(s, size - sz) : 1; } static void @@ -517,6 +517,10 @@ static void hexp_received_telnet(void *_data) sk_send(s, cw->pt); sk_resume_rx(hcs_loop, s); + + hcs_parser_cleanup(s->data); + s->data = hcs_parser_init(s); + rfree(lp); } -- 2.47.2