https://gitlab.synchro.net/main/sbbs/-/commit/cc5aba735c34f4dcbde70869
Modified Files:
src/sftp/sftp.h sftp_client.c sftp_pkt.c
Log Message:
sftp: fix getstring bounds + distinguish do_open failure modes
getstring() bounded against pkt->sz - offsetof(data) - pkt->cur -
sizeof(sz). The extra -sizeof(sz) made the check require 4 bytes of
trailing slop past the string's actual content, which rejected small
valid replies in any packet whose allocation was tight (e.g. the
reply packets extract_packet() hands to the pending waiter). A
redundant second check after get32() duplicated work get32 had
already done. Drop the -sizeof(sz) and the redundant second check;
roll cur back fully on failure so retries see an untouched buffer.
do_open() previously returned false without setting the per-thread
err code when anything other than a real SSH_FXP_STATUS reply went
wrong. Callers saw get_err() == SSH_FX_OK and had no way to tell
whether the send failed, the reply was NULL, or the reply type was
unexpected. Now every failure branch sets a specific code: FAILURE
for local build errors, CONNECTION_LOST for send/delivery failures,
BAD_MESSAGE for unrecognized or malformed replies.
Add sftpc_debug_last_reply_type() exposing the type byte of the most
recent reply for diagnostic messages.
Co-Authored-By: Claude Opus 4.7 (1M context) <
[email protected]>
--- SBBSecho 3.37-Linux
* Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)