From af8de95805c0eea5e3e19d6f74353de3621ced48 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Mon, 15 Jul 2024 12:42:16 +0200 Subject: [PATCH] connector: Fix cycle condition to avoid possible underflow *** CID 1548868: Insecure data handling (INTEGER_OVERFLOW) Signed-off-by: Jakub Jelen Reviewed-by: Sahana Prasad Reviewed-by: Eshan Kelkar --- src/connector.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/connector.c b/src/connector.c index 21c4d79b..9aecf6ea 100644 --- a/src/connector.c +++ b/src/connector.c @@ -291,9 +291,11 @@ static void ssh_connector_fd_in_cb(ssh_connector connector) * Loop around write in case the write blocks even for CHUNKSIZE * bytes */ - while (total != r) { - w = ssh_connector_fd_write(connector, buffer + total, r - total); - if (w < 0){ + while (total < r) { + w = ssh_connector_fd_write(connector, + buffer + total, + r - total); + if (w < 0) { ssh_connector_except(connector, connector->out_fd); return; }