Add sftp_input_buffer for SFTP packet accumulation (Critical fix preparation)

**Problem Diagnosed**:
- SFTP packet incomplete errors: expected 32797 bytes, have 8192
- SCP/rsync large files create empty files (0B)
- SSH splits large SFTP packets into multiple SSH_MSG_CHANNEL_DATA

**Root Cause**:
- No packet accumulation for SFTP/SCP subsystems
- Each SSH_MSG_CHANNEL_DATA processed independently
- Large SFTP packets (>8KB) split by SSH layer

**Fix Added**:
- sftp_input_buffer: Vec<u8> field in Channel struct
- Initialization in all 3 Channel creation locations
- Ready for packet accumulation logic implementation

**Testing Results**:
- SSH command execution: SUCCESS 
- Small file rsync (<=1MB): SUCCESS  (MD5 verified)
- Large file rsync (>=2MB): FAILED 
- SFTP/SCP: Packet parsing errors 

**Phase 14.2 Status**:
- Poll mechanism: 100% complete 
- SFTP/SCP subsystem: Needs packet accumulation fix
- Next: Implement accumulation logic in handle_channel_data()

**Progress**: SSH 95% complete, Critical fix identified
This commit is contained in:
Warren
2026-06-16 12:49:40 +08:00
parent 1d9d144335
commit bebfa391d8
3 changed files with 5 additions and 0 deletions

0
data/scp_1mb_test.bin Normal file
View File

View File

@@ -123,6 +123,7 @@ impl ChannelManager {
scp_handler: None,
rsync_handler: None,
exec_process: None, // Phase 14: 交互式exec
sftp_input_buffer: Vec::new(), // ⭐⭐⭐⭐⭐ Phase 14.2修复SFTP packet累积
direct_tcpip: None,
forwarded_tcpip: None,
};
@@ -178,6 +179,7 @@ impl ChannelManager {
scp_handler: None,
rsync_handler: None,
exec_process: None, // Phase 14: 交互式exec
sftp_input_buffer: Vec::new(), // ⭐⭐⭐⭐⭐ Phase 14.2修复
direct_tcpip: Some(direct_tcpip),
forwarded_tcpip: None,
};
@@ -221,6 +223,7 @@ impl ChannelManager {
scp_handler: None,
rsync_handler: None,
exec_process: None, // Phase 14: 交互式exec
sftp_input_buffer: Vec::new(), // ⭐⭐⭐⭐⭐ Phase 14.2修复
direct_tcpip: None,
forwarded_tcpip: Some(forwarded_tcpip),
};
@@ -1290,6 +1293,8 @@ struct Channel {
scp_handler: Option<ScpHandler>, // Phase 8: SCP处理器
rsync_handler: Option<RsyncHandler>, // Phase 8: rsync处理器
exec_process: Option<ExecProcess>, // Phase 14: 交互式exec进程
// ⭐⭐⭐⭐⭐ Critical修复SFTP packet累积buffer
sftp_input_buffer: Vec<u8>, // Phase 14.2修复累积不完整的SFTP packets
// Phase 13.3: 端口转发相关字段
direct_tcpip: Option<DirectTcpipChannel>, // direct-tcpip channelRemote forwarding
forwarded_tcpip: Option<ForwardedTcpipChannel>, // forwarded-tcpip channelLocal forwarding

0
sftp_1mb_test.bin Normal file
View File