Commit Graph

298 Commits (bfbf0edbb979603ce165a65a0f7101467647a3f2)

Author SHA1 Message Date
John Safranek bfbf0edbb9 7-bit Clean ASCII
Clean up the main set of files to be 7-bit clean ASCII. There were many
single and double-quotes and n-dashes.
2026-04-22 10:27:06 -07:00
John Safranek 87c0b05d72 Userauth none bypasses wolfSSHd credential check
When wolfsshd is built with WOLFSSH_ALLOW_USERAUTH_NONE, the
DefaultUserAuth() function accepted WOLFSSH_USERAUTH_NONE as a valid
auth type and forwarded it to RequestAuthentication(). Since
RequestAuthentication() only gates credential checks on PASSWORD and
PUBLICKEY types, a none request for any existing system user returned
success without verifying any credential. Removed USERAUTH_NONE as an
accepted auth type in DefaultUserAuth() so it is treated as an invalid
auth type for wolfsshd.

Affected function: DefaultUserAuth.
Issue: F-3215
2026-04-21 09:20:12 -07:00
Paul Adelsbach 80da96eebb Add negative test case for CheckPasswordHashUnix 2026-04-20 09:58:07 -07:00
John Safranek 0049c55b1b
Merge pull request #931 from yosuke-wolfssl/f_2074
Fix wolfSSHD_ConfigCopy and wolfSSHD_ConfigFree
2026-04-17 10:24:29 -07:00
Yosuke Shimizu 2608f90fa1 Fix FingerprintKey 2026-04-17 17:52:30 +09:00
Yosuke Shimizu 97a0c7b5b7 Fix wolfSSHD_ConfigCopy and wolfSSHD_ConfigFree, and Add the regression test 2026-04-17 17:31:40 +09:00
Paul Adelsbach 854a36248e Replace WMEMCMP in CheckAuthKeysLine 2026-04-13 10:19:24 -07:00
Yosuke Shimizu d0aad2be69 Fix f_405 2026-03-27 08:24:23 +09:00
Yosuke Shimizu 087fba94bb Fix f_404 2026-03-27 08:24:23 +09:00
John Safranek 2f1231d185 macOS Semaphore Cleanup
macOS uses GCD for threading and semaphores, but they aren't quite like
POSIX semaphores. macOS allows the use of named POSIX semaphores.

1. Convert the semaphores to named POSIX semaphores.
2. Simplify all calls for semaphores into single function calls of the
   wrapper API.
3. Update both examples/client/client.c and apps/wolfssh/wolfssh.c.
4. Update both to deregister the WINCH signal.
2026-03-17 19:26:32 -07:00
John Safranek 801ac0701d Non-constant-time password hash comparison
In wolfSSHd, the comparisons of the password hash and public keys were
using memcmp(). Changed to use ConstantCompare().

Affected functions: CheckPasswordHashUnix, CheckPublicKeyUnix.
Issue: F-53
2026-03-16 14:20:18 -07:00
John Safranek b048f18d8c
Merge pull request #885 from padelsbach/padelsbach/finding-401-402-403
Fix multibyte passwords, file mode and attrib reporting
2026-03-09 10:27:56 -07:00
JacobBarthelmeh 1e1140aa5a
Merge pull request #883 from ejohnstown/static-fixes
Static analysis fixes
2026-03-06 10:09:29 -07:00
John Safranek 3cfec8b3d2 Missing ForceZero on plaintext password copy
When a copy of the user's password is freed, it wasn't getting force
zeroed. It might still exist in the heap after getting freed.  Added
a call to `ForceZero()`.

Affected function: CheckPasswordUnix.
Issue: F-56
2026-03-05 10:45:37 -08:00
John Safranek 2da09427cd Operator Precedence Bug
Added parens around an assignment to a variable before it is compared to
an expected value.

Affected function: SetupUserTokenWin.
Issue: F-210
2026-03-05 10:43:56 -08:00
Paul Adelsbach 0458d83137 Fix multibyte passwords, file mode and attrib reporting 2026-03-04 15:29:36 -08:00
aidan garske 09144d0c7a Add more wolfSSH CI workflows 2026-03-03 21:22:39 -08:00
John Safranek d6e1b04316 Check correct pointer for null
After creating a new SSH context, the pointer returned wasn't checked;
the pointer to the pointer was checked. Changed to the correct pointer.

Affected function: SetupCTX.
2026-02-24 16:43:18 -08:00
John Safranek c802a7faf4 Fix null check for duplicated string
When making a copy of a string, check the destination pointer of the
copy rather than the original.

Affected function: CheckPasswordUnix.
2026-02-24 16:15:11 -08:00
Andrew Hutchings 99319bf773 Fix wrong variable checked in DoCheckUser auth callback
In DoCheckUser, after calling auth->checkUserCb(usr) into rc, the
failure check on line 1063 compared ret instead of rc against
WSSHD_AUTH_FAILURE. Since ret is WOLFSSH_USERAUTH_SUCCESS at that
point, the condition was always false, causing callback failures to
fall through to the generic error branch with WOLFSSH_USERAUTH_FAILURE
instead of returning WOLFSSH_USERAUTH_INVALID_USER.
2026-02-23 10:21:35 +00:00
JacobBarthelmeh 069dcc0949 fix for warning with snprintf use in test case 2026-01-09 10:56:11 -07:00
John Safranek 8951bd9209 Release v1.4.22
1. Update copyright date to 2026.
2025-12-29 16:53:33 -08:00
Daniel Pouzzner 3636446baf
Merge pull request #852 from divinity76/fix-sys-errno
replace sys/errno.h with errno.h
2025-12-15 10:42:26 -06:00
Andrew Hutchings dee1c59f26 Fix double-free crash and socket-close spin 2025-12-09 09:36:38 -08:00
hanshenrik 44dc148dbd replace sys/errno.h with errno.h
Historically, some systems have used <sys/errno.h> in place of <errno.h>, but the C standard,
 all the way back to C89/Ansi C, specifies that the correct name is `errno.h` -
and most modern compilers create a sys/errno.h compatibility shim sys/errno.h -
but musl-gcc does not have this compatibility shim,
 reasoning that sys/errno.h is non-standard, and fails to compile:
```
$ CC=musl-gcc ./configure --enable-static --disable-shared --enable-scp --enable-sftp --enable-shell --with-wolfssl=wolfssl/install-musl
(...)
$ make
make -j17  all-am
make[1]: Entering directory '/home/hans/projects/wolfssh'
  CC       examples/client/common.o
  CC       examples/client/client.o
  CC       src/libwolfssh_la-ssh.lo
  CC       src/libwolfssh_la-internal.lo
  CC       src/libwolfssh_la-log.lo
  CC       src/libwolfssh_la-port.lo
  CC       src/libwolfssh_la-io.lo
  CC       src/libwolfssh_la-wolfscp.lo
  CC       src/libwolfssh_la-wolfsftp.lo
  CC       examples/echoserver/echoserver.o
  CC       src/libwolfssh_la-wolfterm.lo
  CC       examples/sftpclient/sftpclient.o
  CC       examples/scpclient/scpclient.o
In file included from examples/echoserver/echoserver.c:91:
/usr/include/x86_64-linux-musl/sys/errno.h:1:2: error: #warning redirecting incorrect #include <sys/errno.h> to <errno.h> [-Werror=cpp]
    1 | #warning redirecting incorrect #include <sys/errno.h> to <errno.h>
      |  ^~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:1452: examples/echoserver/echoserver.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/hans/projects/wolfssh'
make: *** [Makefile:1020: all] Error 2
```

so, unless we need to support pre-C89 (35+ year old C) compilers,
we can just replace sys/errno.h with errno.h.
2025-11-22 17:40:20 +01:00
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