Skip to content

Commit

Permalink
Merge pull request #655 from JacobBarthelmeh/sshd_forcedcmd
Browse files Browse the repository at this point in the history
set pipes as non blocking before last read
  • Loading branch information
ejohnstown authored Feb 13, 2024
2 parents 2d8bb0f + 46cdfc5 commit 71ba56a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/wolfsshd/wolfsshd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1606,11 +1606,15 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
if (forcedCmd) {
int readSz;

fcntl(stdoutPipe[0], F_SETFL, fcntl(stdoutPipe[0], F_GETFL)
| O_NONBLOCK);
readSz = (int)read(stdoutPipe[0], shellBuffer, sizeof shellBuffer);
if (readSz > 0) {
wolfSSH_ChannelIdSend(ssh, shellChannelId, shellBuffer, readSz);
}

fcntl(stderrPipe[0], F_SETFL, fcntl(stderrPipe[0], F_GETFL)
| O_NONBLOCK);
readSz = (int)read(stderrPipe[0], shellBuffer, sizeof shellBuffer);
if (readSz > 0) {
wolfSSH_extended_data_send(ssh, shellBuffer, readSz);
Expand Down

0 comments on commit 71ba56a

Please sign in to comment.