File libssh2_org-CVE-2019-3860-fix.patch of Package libssh2_org.30348

From 85dbd4c1367b8f712b0ad8145f35ec1ee802fe06 Mon Sep 17 00:00:00 2001
From: Jakob Egger <jakob@eggerapps.at>
Date: Thu, 4 Feb 2016 12:10:47 +0100
Subject: [PATCH] sftp.c: ensure minimum read packet size

For optimum performance we need to ensure we don't request tiny packets.
---
 src/sftp.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Index: libssh2-1.4.3/src/sftp.c
===================================================================
--- libssh2-1.4.3.orig/src/sftp.c
+++ libssh2-1.4.3/src/sftp.c
@@ -1435,12 +1435,12 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HA
 
         while(count > 0) {
             unsigned char *s;
-            uint32_t size = MIN(MAX_SFTP_READ_SIZE, count);
 
             /* 25 = packet_len(4) + packet_type(1) + request_id(4) +
                handle_len(4) + offset(8) + count(4) */
             uint32_t packet_len = (uint32_t)handle->handle_len + 25;
             uint32_t request_id;
+            uint32_t size = count;
 
 	    if(size < buffer_size)
 		size = buffer_size;
@@ -1471,8 +1471,8 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HA
 
             /* add this new entry LAST in the list */
             _libssh2_list_add(&handle->packet_list, &chunk->node);
-            count -= size; /* deduct the size we used, as we might have
-                              to create more packets */
+            count -= MIN(size,count); /* deduct the size we used, as we might
+                                       * have to create more packets */
         }
 
     case libssh2_NB_state_sent:
openSUSE Build Service is sponsored by