Skip to content

Commit 3859213

Browse files
use childFd when not handling a forced command
1 parent 60cd4bc commit 3859213

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

apps/wolfsshd/wolfsshd.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,8 +1511,14 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
15111511
if (cnt_r <= 0)
15121512
break;
15131513

1514-
cnt_w = (int)write(stdinPipe[1], channelBuffer,
1515-
cnt_r);
1514+
if (forcedCmd) {
1515+
cnt_w = (int)write(stdinPipe[1], channelBuffer,
1516+
cnt_r);
1517+
}
1518+
else {
1519+
cnt_w = (int)write(childFd, channelBuffer,
1520+
cnt_r);
1521+
}
15161522
if (cnt_w <= 0)
15171523
break;
15181524
}
@@ -1545,7 +1551,7 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
15451551
current = wolfSSH_ChannelFind(ssh, lastChannel,
15461552
WS_CHANNEL_ID_SELF);
15471553
eof = wolfSSH_ChannelGetEof(current);
1548-
if (eof) {
1554+
if (eof && forcedCmd) {
15491555
/* SSH is done, close stdin pipe to child process */
15501556
close(stdinPipe[1]);
15511557
stdinPipe[1] = -1;

0 commit comments

Comments
 (0)