Uint8Array views that fail Buffer.isBuffer; READ/CLOSE/FSTAT/WRITE/READDIR were rejecting every request with SSH_FX_FAILURE. Add sftpHandleId() using DataView. OPEN: fix inner try indentation. CHANGELOG: note handle decoding + earlier SFTP hardening (vfs normalize, enqueueSftpReply, Protocol/SFTP DATA coerce).
1.3 KiB
1.3 KiB
Changelog
Unreleased
- SFTP stability: Harden
REQUEST.READparsing in vendoredbare-ssh2(handle/offset/lenmust be defined before emit). AlignWRITEandFSETSTATguards with other handle-based handlers. - Bare OS SFTP shim:
enqueueSftpReplynow takesreqidand sendsSSH_FX_FAILUREif the queued handler throws or rejects, avoiding stalled clients and reducing risk of uncaught SFTP-path errors surfacing as native aborts (bad_optional_accessunder-fno-exceptions) after the serialized-reply ordering change. - SFTP DATA / channel binary: Coerce
Uint8Array(and other typed views) toBufferinSFTP.prototype.dataandProtocol.channelData/channelExtData. VFS-backed file buffers are often typed arrays; treating them as UTF-8 strings whenBuffer.isBufferis false corrupted SSH channel packets and could abort the runtime withbad_optional_access. - SFTP OPEN/READ: Normalize
vfs.readFileresults toBufferbefore storing handles; treat empty buffer as readable (!f.bufwrongly failed for""/ edge cases). READ acceptsBufferor typed views after WRITE. - SFTP handles: Decode inbound file/dir handles with
DataViewwhen bare-ssh2 passesUint8Array/ safer-buffer slices that failBuffer.isBuffer— READ/CLOSE/FSTAT/WRITE/READDIR no longer always return SSH_FX_FAILURE on Bare.