@@ -1418,7 +1418,11 @@ int wolfSSH_SFTP_read(WOLFSSH* ssh)
14181418 ret = wolfSSH_SFTP_buffer_read (ssh , & state -> buffer ,
14191419 state -> buffer .sz );
14201420 if (ret < 0 ) {
1421- if (!NoticeError (ssh )) {
1421+ if (NoticeError (ssh )) {
1422+ /* keep state for returning to */
1423+ ret = WS_FATAL_ERROR ;
1424+ }
1425+ else {
14221426 wolfSSH_SFTP_ClearState (ssh , STATE_ID_RECV );
14231427 }
14241428 return ret ;
@@ -7452,8 +7456,7 @@ int wolfSSH_SFTP_SendWritePacket(WOLFSSH* ssh, byte* handle, word32 handleSz,
74527456 /* send header and type specific data */
74537457 ret = wolfSSH_SFTP_buffer_send (ssh , & state -> buffer );
74547458 if (ret < 0 ) {
7455- if (ssh -> error == WS_WANT_READ ||
7456- ssh -> error == WS_WANT_WRITE ) {
7459+ if (NoticeError (ssh )) {
74577460 return WS_FATAL_ERROR ;
74587461 }
74597462 state -> state = STATE_SEND_WRITE_CLEANUP ;
@@ -7465,12 +7468,8 @@ int wolfSSH_SFTP_SendWritePacket(WOLFSSH* ssh, byte* handle, word32 handleSz,
74657468 case STATE_SEND_WRITE_SEND_BODY :
74667469 WLOG (WS_LOG_SFTP , "SFTP SEND_WRITE STATE: SEND_BODY" );
74677470 state -> sentSz = wolfSSH_stream_send (ssh , in , inSz );
7468- if (state -> sentSz == WS_WINDOW_FULL ||
7469- state -> sentSz == WS_REKEYING ||
7470- state -> sentSz == WS_WANT_READ ||
7471- state -> sentSz == WS_WANT_WRITE ) {
7472- ret = wolfSSH_worker (ssh , NULL );
7473- continue ; /* skip past rest and send more */
7471+ if (NoticeError (ssh )) {
7472+ return WS_FATAL_ERROR ;
74747473 }
74757474 if (state -> sentSz <= 0 ) {
74767475 ssh -> error = state -> sentSz ;
@@ -7496,8 +7495,7 @@ int wolfSSH_SFTP_SendWritePacket(WOLFSSH* ssh, byte* handle, word32 handleSz,
74967495 state -> maxSz = SFTP_GetHeader (ssh , & state -> reqId , & type ,
74977496 & state -> buffer );
74987497 if (state -> maxSz <= 0 ) {
7499- if (ssh -> error == WS_WANT_READ ||
7500- ssh -> error == WS_WANT_WRITE ) {
7498+ if (NoticeError (ssh )) {
75017499 return WS_FATAL_ERROR ;
75027500 }
75037501 ssh -> error = WS_SFTP_BAD_HEADER ;
@@ -9167,10 +9165,9 @@ int wolfSSH_SFTP_Put(WOLFSSH* ssh, char* from, char* to, byte resume,
91679165 state -> handle , state -> handleSz , state -> pOfst ,
91689166 state -> r , state -> rSz );
91699167 if (sz <= 0 ) {
9170- if (ssh -> error == WS_WANT_READ ||
9171- ssh -> error == WS_WANT_WRITE ||
9172- ssh -> error == WS_WINDOW_FULL )
9168+ if (NoticeError (ssh )) {
91739169 return WS_FATAL_ERROR ;
9170+ }
91749171 }
91759172 else {
91769173 AddAssign64 (state -> pOfst , sz );
0 commit comments