mirror of
				https://github.com/libssh2/libssh2.git
				synced 2025-11-03 22:13:11 +03:00 
			
		
		
		
	libssh2_sftp_read should not return error if it receives SSH_FX_EOF code in
SSH_FXP_STATUS packet. (Thanks to elifantu@mail.ru for the patch)
This commit is contained in:
		
							
								
								
									
										15
									
								
								src/sftp.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								src/sftp.c
									
									
									
									
									
								
							@@ -712,11 +712,18 @@ static ssize_t _libssh2_sftp_read(LIBSSH2_SFTP_HANDLE *handle,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        switch (data[0]) {
 | 
					        switch (data[0]) {
 | 
				
			||||||
                case SSH_FXP_STATUS:
 | 
					                case SSH_FXP_STATUS:
 | 
				
			||||||
                        sftp->last_errno = libssh2_ntohu32(data + 5);
 | 
					                {
 | 
				
			||||||
                        libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
 | 
					                        int retcode = libssh2_ntohu32(data + 5);
 | 
				
			||||||
                                      "SFTP Protocol Error", 0);
 | 
					 | 
				
			||||||
                        LIBSSH2_FREE(session, data);
 | 
					                        LIBSSH2_FREE(session, data);
 | 
				
			||||||
                        return -1;
 | 
					
 | 
				
			||||||
 | 
					                        if (retcode == LIBSSH2_FX_EOF) {
 | 
				
			||||||
 | 
					                                return 0;
 | 
				
			||||||
 | 
					                        } else {
 | 
				
			||||||
 | 
					                                sftp->last_errno = retcode;
 | 
				
			||||||
 | 
					                                libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL, "SFTP Protocol Error", 0);
 | 
				
			||||||
 | 
					                                return -1;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        
 | 
				
			||||||
                case SSH_FXP_DATA:
 | 
					                case SSH_FXP_DATA:
 | 
				
			||||||
                        bytes_read = libssh2_ntohu32(data + 5);
 | 
					                        bytes_read = libssh2_ntohu32(data + 5);
 | 
				
			||||||
                        if (bytes_read > (data_len - 9)) {
 | 
					                        if (bytes_read > (data_len - 9)) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user