Merge pull request #655 from JacobBarthelmeh/sshd_forcedcmd

set pipes as non blocking before last read
pull/658/head
John Safranek 2024-02-13 10:57:45 -08:00 committed by GitHub
commit 71ba56a7d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 0 deletions

View File

@ -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);