Commit Graph

273 Commits (2fa166f227351110838221af30b0212cc93f9166)

Author SHA1 Message Date
JacobBarthelmeh 91c9279c22 simplify wolfSSH_ChannelIsPty to only take a pointer to a channel 2025-09-17 15:13:23 -06:00
JacobBarthelmeh 7c9f8f1758 refactor pty flag to Channel level and treat result as boolean in wolfsshd checks 2025-09-17 14:03:05 -06:00
JacobBarthelmeh 6fe09bdb35 do not treat shell as interactive until pty-req received 2025-09-16 10:31:38 -06:00
JacobBarthelmeh 73cf79e2ce clang scan-build warning fix 2025-07-25 11:32:02 -06:00
John Safranek 903bbc7fb2 Coverity: Argument cannot be negative
1. Due to not checking the result of fseek(), it is possible to try to
   malloc() -1 bytes of storage. Checking the return from fseek() and
   erring if negative.
2. Changing the check between the result of fseek() and fread() to match
   signedness. Adding some casting, as at that point the fseek() result
   is always positive.

Fixes CIDs:
  573009 572928 572868
2025-07-21 09:36:35 -07:00
John Safranek c641294fc3 Coverity: Buffer not null terminated
1. When copying the shell, leave a byte free in the dest buffer. Fill it
   with a null.

Fixes CID: 572891
2025-07-21 09:17:21 -07:00
John Safranek 4700799fcc Coverity: Dereference before null check
1. After getting the user's pw info, don't check that the shell value is
   null. We've already use it at that point.

Fixes CID: 572919
2025-07-21 09:17:21 -07:00
John Safranek 441f975ed6 Coverity: 'Constant' variable guards dead code
1. Remove the default password from the wolfSSH client app main
   function. It isn't set to anything. (It was originally an example
   client option.)
2. Remove handling the default password from the wolfSSH client app's
   user authentication callback.
3. Set the password size directly.
4. Changed a void typecast to WOLFSSH_UNUSED.

Fixes CID: 572898
2025-07-11 14:50:22 -07:00
John Safranek 538ae15310 Coverity: Resource leak
1. Fix some resource leaks during error conditions where a socket or a
   file descriptor doesn't get closed in all error cases.
2. In wolfSSH_SFTP_RecvOpen(), initialize the file descriptor.
3. For 572902, the error case resource leaks are fixed. There's still an
   issue to resolve for storing the FD for use later.

Fixes CIDs:
  572856 572902* 573012 573019 573021 573076
2025-07-11 14:06:46 -07:00
David Garske 055d024b2e
Merge pull request #776 from JacobBarthelmeh/wolfsshd
fix for FD_SET call on pipes and handling of channel EOF
2025-02-19 12:35:27 -08:00
JacobBarthelmeh 3859213936 use childFd when not handling a forced command 2025-02-19 12:00:38 -07:00
JacobBarthelmeh 60cd4bca73 redirect stdin with forced command 2025-02-19 10:32:08 -07:00
Andrew Hutchings a9c7ebc36d Fix SCP server side
SCP on the server side would get an EAGAIN around the 128KB mark, which
would trigger an error. That error in-turn would cause two attempts to
close the file, which would segfault.

Also fix inverted error return status on scpclient.
2025-02-19 11:13:42 +00:00
JacobBarthelmeh bbe3bac2d5 add regression test and use a better macro name 2025-02-18 10:50:05 -07:00
JacobBarthelmeh ab3622e672 fix for FD_SET call on pipes and handling of channel EOF 2025-02-17 10:07:39 -07:00
JacobBarthelmeh 34c3794396
Merge pull request #768 from LinuxJedi/client-crash
Fix crash when client has no hostname
2025-02-10 16:34:46 -07:00
Andrew Hutchings d108c69c5d Add cppcheck test to GitHub actions
Found and fixed:

* Fix typos in Renesas demo
* Fix uninitialized variable reads
* Fix redundant condition
* Fix argument checks
* Fix some null ptr dereferences
* Fix ambiguous statement
2025-02-05 19:49:01 +00:00
Andrew Hutchings 669bf92683 Fix crash when client has no hostname
If the client is not provided a hostname, `ClientPublicKeyCheck` would
crash trying to match `targetName`. A hostname is required.
2025-02-04 11:18:51 +00:00
JacobBarthelmeh c476e8846e refactor sshd test case script 2025-01-30 18:16:55 -07:00
JacobBarthelmeh c2fefec0eb add debug print out with test case 2025-01-30 17:42:44 -07:00
JacobBarthelmeh e4356dd6ed add test case 2025-01-30 17:31:05 -07:00
JacobBarthelmeh ce5b401ebd add regression test for closing down child on SSH connection issue 2024-11-26 12:01:23 -07:00
JacobBarthelmeh c8692f7570 kill child process after SSH connection failure 2024-11-25 16:36:54 -07:00
JacobBarthelmeh 6e70a07cfd fix for handling memory on socket timeout 2024-11-15 11:10:16 -07:00
Daniel Pouzzner d3a8ec6dc0
Merge pull request #743 from JacobBarthelmeh/sftp
keep trailing delimiter with SFTP open
2024-11-01 14:24:23 -05:00
JacobBarthelmeh 9e68977945 test setting different wolfssl version for test 2024-10-11 16:23:20 -06:00
John Safranek 8d1efe9fdf Testing Update
1. Update the sshd test to use the newer actions.
2. Parameterize the test for macos and ubuntu.
3. Parameterize the version of wolfssl used.
4. Parameterize the wolfSSH options used.
5. Update a couple test scripts to output their $0 variable instead of
   the wrong string.
2024-10-04 15:44:15 -06:00
JacobBarthelmeh 52e4e32529 keep trailing delimiter with SFTP open 2024-10-04 14:59:40 -06:00
JacobBarthelmeh b8e6f595b4 show version of wolfSSL linked to 2024-09-27 14:36:42 -06:00
John Safranek f51889430f
Merge pull request #732 from JacobBarthelmeh/scp_example
continue to cleanup on fail case and use WLOG for debug messages
2024-08-08 18:11:06 -07:00
JacobBarthelmeh 2fbe01092d account for partial sends 2024-08-05 14:48:51 -06:00
JacobBarthelmeh 15f4dc9d0f adjustments to test case 2024-08-05 13:31:47 -06:00
JacobBarthelmeh 781aa27582 touch up after rebase 2024-08-05 13:31:47 -06:00
JacobBarthelmeh 46832e46b4 add test case 2024-08-05 13:31:47 -06:00
JacobBarthelmeh 2722cb9da8 handle send retry when SSH window is full 2024-08-05 13:31:47 -06:00
JacobBarthelmeh fdecd765b9 continue to cleanup on fail case and use WLOG for debug messages 2024-08-05 13:23:04 -06:00
John Safranek a4f860d071 Release v1.4.18: Release Fixes
1. Update scp.test to delete the empty test file.
2. In wolfSSHd, when coverting an IP address to a printable
   representation, the destination needs to be able to handle IPv6
   addresses potentially.
2024-07-19 14:38:07 -07:00
John Safranek 1a6225671b Release v1.4.18: Release Testing Fixes (Windows)
1. For the ASCII and Wide versions of types and functions, make sure
   the wolfSSHd is being consistent using them.
2. In SFTP, use WSOCKETCLOSE to close the socket. Use the correct type
   for the socket.
3. Add parens around part of a ternary operator check to clear up some
   ambiguous order of operations.
4. Add a variable initializer for a COORD structure.
5. Add parameter checks to the Base16_Decode function.
6. Fix a double-freed handle.
7. Clean up a bunch of build warnings.
2024-07-19 12:03:32 -07:00
John Safranek e7ad7dd922
Merge pull request #722 from JacobBarthelmeh/sshd-windows
Fixes for SSHD Windows virtual terminal sequences
2024-07-17 14:06:37 -07:00
Daniel Pouzzner 01c1aadfba
Merge pull request #720 from ejohnstown/sshd-banner
SSHD Banners
2024-07-16 15:43:17 -05:00
Daniel Pouzzner e3bed88ead
Merge pull request #718 from ejohnstown/wolfsshd-closure
wolfSSHd Connection Closure
2024-07-16 15:41:50 -05:00
John Safranek 6c69c12bf7 wolfSSHd Connection Closure
1. Initialize all the fds to -1.
2. Add flags for peerConnected and stdoutEmpty.
3. Remove the idle counter.
4. When the socket would block on write, set a flag to check the socket for
   writing later to call the worker which will send pending data.
5. When reading the pipes, a 0 returns means the pipe is closed. Deal
   with that.
6. If the ssh write fails, interrupt the subordinate process.
7. When waiting for the peer to close its channel and shutdown, sleep
   for 100ms, rather than 1us. It takes a little while to tear down.
8. Shutdown the peer socket. Spin on receiving the peer socket until it
   closes or has an error.
9. Fixed a few function wrappers; was using Xname instead of Wname.
2024-07-16 10:50:12 -07:00
Lealem Amedie 5ea74bc22d Free resources 2024-07-15 17:19:20 -06:00
JacobBarthelmeh 89a24568a6 remove extra debug print outs 2024-07-12 01:02:33 -06:00
JacobBarthelmeh 25a0414378 handling virtual terminal sequences with exec command 2024-07-12 00:43:13 -06:00
Lealem Amedie b0cf4cfa5d Don't exit wolfSSHd daemon on recoverable fcntl failure 2024-07-11 16:56:39 -06:00
Lealem Amedie ff3e0177f7 Don't set banner unless specified in config 2024-07-10 15:06:51 -07:00
John Safranek 0f9e87357b
Merge pull request #715 from JacobBarthelmeh/examples
case of non-console ouptut handle
2024-07-10 11:20:32 -07:00
John Safranek 7fc63e86bf SSHD Banners
1. Add getting the banner option from the configuration file. Per the
   sshd_config(5) manpage, this is supposed to be a filename.
2. Load the banner file and set the banner into the CTX.
2024-07-08 10:02:41 -07:00
Eric Blankenhorn 0719578e29 Fix testsuite with singlethreaded 2024-07-01 09:12:36 -05:00