1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-12-24 19:37:48 +03:00

connector: Fix cycle condition to avoid possible underflow

*** CID 1548868:  Insecure data handling  (INTEGER_OVERFLOW)

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Eshan Kelkar <eshankelkar@galorithm.com>
This commit is contained in:
Jakub Jelen
2024-07-15 12:42:16 +02:00
committed by Sahana Prasad
parent 17a8a8b3c3
commit af8de95805

View File

@@ -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;
}