@@ -1515,8 +1515,10 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
15151515 }
15161516 else {
15171517 windowFull -= cnt_w ;
1518- if (windowFull > 0 )
1518+ if (windowFull > 0 ) {
1519+ WMEMMOVE (shellBuffer , shellBuffer + cnt_w , windowFull );
15191520 continue ;
1521+ }
15201522 if (windowFull < 0 )
15211523 windowFull = 0 ;
15221524 }
@@ -1537,7 +1539,13 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
15371539 if (cnt_r > 0 ) {
15381540 cnt_w = wolfSSH_extended_data_send (ssh , shellBuffer ,
15391541 cnt_r );
1540- if (cnt_w == WS_WINDOW_FULL || cnt_w == WS_REKEYING ) {
1542+ if (cnt_w > 0 && cnt_w < cnt_r ) { /* partial send */
1543+ windowFull = cnt_r - cnt_w ;
1544+ WMEMMOVE (shellBuffer , shellBuffer + cnt_w ,
1545+ windowFull );
1546+ }
1547+ else if (cnt_w == WS_WINDOW_FULL ||
1548+ cnt_w == WS_REKEYING ) {
15411549 windowFull = cnt_r ; /* save amount to be sent */
15421550 continue ;
15431551 }
@@ -1569,7 +1577,13 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
15691577 if (cnt_r > 0 ) {
15701578 cnt_w = wolfSSH_ChannelIdSend (ssh , shellChannelId ,
15711579 shellBuffer , cnt_r );
1572- if (cnt_w == WS_WINDOW_FULL || cnt_w == WS_REKEYING ) {
1580+ if (cnt_w > 0 && cnt_w < cnt_r ) { /* partial send */
1581+ windowFull = cnt_r - cnt_w ;
1582+ WMEMMOVE (shellBuffer , shellBuffer + cnt_w ,
1583+ windowFull );
1584+ }
1585+ else if (cnt_w == WS_WINDOW_FULL ||
1586+ cnt_w == WS_REKEYING ) {
15731587 windowFull = cnt_r ; /* save amount to be sent */
15741588 continue ;
15751589 }
@@ -1599,7 +1613,13 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
15991613 if (cnt_r > 0 ) {
16001614 cnt_w = wolfSSH_ChannelIdSend (ssh , shellChannelId ,
16011615 shellBuffer , cnt_r );
1602- if (cnt_w == WS_WINDOW_FULL || cnt_w == WS_REKEYING ) {
1616+ if (cnt_w > 0 && cnt_w < cnt_r ) { /* partial send */
1617+ windowFull = cnt_r - cnt_w ;
1618+ WMEMMOVE (shellBuffer , shellBuffer + cnt_w ,
1619+ windowFull );
1620+ }
1621+ else if (cnt_w == WS_WINDOW_FULL ||
1622+ cnt_w == WS_REKEYING ) {
16031623 windowFull = cnt_r ;
16041624 continue ;
16051625 }
0 commit comments