mirror of https://github.com/pkg/sftp.git
				
				
				
			fix: maybe hang for process *sshfx.ReadPacket for *Server.handle()"
In `*Server.handle`, if the sshfx.ReadPacket's Length is less than maxDataLen, the client may get stuck during data reading.
This commit is contained in:
		
							parent
							
								
									630bb7f768
								
							
						
					
					
						commit
						9033c1b187
					
				|  | @ -699,7 +699,7 @@ func (srv *Server) handle(req sshfx.Packet, hint []byte, maxDataLen uint32) (ssh | ||||||
| 				return nil, fmt.Errorf("read length request too large: %d", req.Length) | 				return nil, fmt.Errorf("read length request too large: %d", req.Length) | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			n, err := file.ReadAt(hint, int64(req.Offset)) | 			n, err := file.ReadAt(hint[:req.Length], int64(req.Offset)) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				// We cannot return results AND a status like SSH_FX_EOF,
 | 				// We cannot return results AND a status like SSH_FX_EOF,
 | ||||||
| 				// so we return io.EOF only if we didn't read anything at all.
 | 				// so we return io.EOF only if we didn't read anything at all.
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue