mirror of
				https://github.com/libssh2/libssh2.git
				synced 2025-11-03 22:13:11 +03:00 
			
		
		
		
	decomp: increase decompression buffer sizes
This commit is contained in:
		
				
					committed by
					
						
						Daniel Stenberg
					
				
			
			
				
	
			
			
			
						parent
						
							8974dc05ae
						
					
				
				
					commit
					7603c0f854
				
			@@ -233,7 +233,7 @@ comp_method_zlib_decomp(LIBSSH2_SESSION * session,
 | 
				
			|||||||
    /* A short-term alloc of a full data chunk is better than a series of
 | 
					    /* A short-term alloc of a full data chunk is better than a series of
 | 
				
			||||||
       reallocs */
 | 
					       reallocs */
 | 
				
			||||||
    char *out;
 | 
					    char *out;
 | 
				
			||||||
    int out_maxlen = compress ? (src_len + 4) : (2 * src_len);
 | 
					    int out_maxlen = compress ? (src_len + 4) : (8 * src_len);
 | 
				
			||||||
    int limiter = 0;
 | 
					    int limiter = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* If strm is null, then we have not yet been initialized. */
 | 
					    /* If strm is null, then we have not yet been initialized. */
 | 
				
			||||||
@@ -284,7 +284,7 @@ comp_method_zlib_decomp(LIBSSH2_SESSION * session,
 | 
				
			|||||||
            char *newout;
 | 
					            char *newout;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            out_maxlen +=
 | 
					            out_maxlen +=
 | 
				
			||||||
                compress ? (strm->avail_in + 4) : (2 * strm->avail_in);
 | 
					                compress ? (strm->avail_in + 4) : (8 * strm->avail_in);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if ((out_maxlen > (int) payload_limit) && !compress && limiter++) {
 | 
					            if ((out_maxlen > (int) payload_limit) && !compress && limiter++) {
 | 
				
			||||||
                LIBSSH2_FREE(session, out);
 | 
					                LIBSSH2_FREE(session, out);
 | 
				
			||||||
@@ -302,14 +302,14 @@ comp_method_zlib_decomp(LIBSSH2_SESSION * session,
 | 
				
			|||||||
            out = newout;
 | 
					            out = newout;
 | 
				
			||||||
            strm->next_out = (unsigned char *) out + out_ofs;
 | 
					            strm->next_out = (unsigned char *) out + out_ofs;
 | 
				
			||||||
            strm->avail_out +=
 | 
					            strm->avail_out +=
 | 
				
			||||||
                compress ? (strm->avail_in + 4) : (2 * strm->avail_in);
 | 
					                compress ? (strm->avail_in + 4) : (8 * strm->avail_in);
 | 
				
			||||||
        } else
 | 
					        } else
 | 
				
			||||||
            while (!strm->avail_out) {
 | 
					            while (!strm->avail_out) {
 | 
				
			||||||
                /* Done with input, might be a byte or two in internal buffer
 | 
					                /* Done with input, might be a byte or two in internal buffer
 | 
				
			||||||
                 * during compress.  Or potentially many bytes if it's a
 | 
					                 * during compress.  Or potentially many bytes if it's a
 | 
				
			||||||
                 * decompress
 | 
					                 * decompress
 | 
				
			||||||
                 */
 | 
					                 */
 | 
				
			||||||
                int grow_size = compress ? 8 : 1024;
 | 
					                int grow_size = compress ? 8 : 2048;
 | 
				
			||||||
                char *newout;
 | 
					                char *newout;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (out_maxlen >= (int) payload_limit) {
 | 
					                if (out_maxlen >= (int) payload_limit) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user