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.
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
1. When cleaning the path, check that the path pointer is not null
before using it.
2. Move the strlen of path.
3. Remove the second check of path, and just loop over it.
Fixed CID: 572847
1. Modify all the test executable `CPPFLAGS` to only have
`-DNO_MAIN_LOOP` and `AM_CPPFLAGS`. This removes a lot of duplicate
setup of flags for each of the tests.
2. Delete the echoserver's `CFLAGS`. It is just setting the `CFLAGS` for
its compile to `AM_CFLAGS` and `AM_CPPFLAGS` which are included by
default.
3. Add the macro WS_MAYBE_UNUSED that may be the unused attribute.
4. If INLINE isn't set to some form of inline, set it to
WS_MAYBE_UNUSED.
5. Remove redundant ThreadStartNoJoin() macros from the testing header.
1. By default, soft disable AES-CBC. It isn't offered as a default
encrypt algorithm, but may be set at runtime.
2. Add guard where AES-CBC can be added back as a default.
3. Add option to example client to run it with a custom encrypt
algorithm list.
4. In the client, add macro to add items to the arg lists while checking
the number of items in the list.
* Update myStatusCb to output once per second
Modified the myStatusCb function in sftpclient.c to only output status
updates once per second by tracking the last output time and comparing
it with the current time. This reduces the frequency of status updates
while maintaining all existing functionality.
Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
* Reset status output timer when starting new file transfer
When starting a new file transfer, reset the lastOutputTime to ensure
the first status update for the new file is shown immediately.
Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
* Fix Zephyr build by guarding lastOutputTime with WOLFSSH_NO_TIMESTAMP
The lastOutputTime variable is only used when timestamps are enabled,
so it should be guarded by the same macro to avoid unused variable
warnings in builds where timestamps are disabled.
Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
* Move elapsedTime declaration to function scope
Per wolfSSL coding standards, declare all variables at function scope.
Added comment explaining that modern compilers optimize variable access
regardless of declaration placement.
Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
* Fix timeout check to use elapsed time instead of current time
Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
* Use elapsed time in timeout error message for consistency
Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
* Move elapsedTime inside WOLFSSH_NO_TIMESTAMP guard
Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
* Move currentTime outside WOLFSSH_NO_TIMESTAMP guard
Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: andrew@wolfssl.com <andrew@wolfssl.com>
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.
This adds the `diffie-hellman-group16-sha512` key exchange and
`hmac-sha2-512` mac support.
Echoserver can now take `-x` for key exchange and `-m` for mac setting,
and `-c` for cipher so that this can be used in the test suite.
This implements Keyboard-Interactive authentication.
Adds an additional callback set by `wolfSSH_KeyboarAuthPrompts()` which
will set a callback in the server to ask the application to provide the
prompt details for the client.
1. Fix echoserver's load_file function. Could potentially dereference
null if a file size is passed in, but using a null buf to get the
file's size only.
1. Add the code from wolfsshd that initially sets up the terminal
settings to the echoserver.
2. Add the WOLFSSH_TERM flag to the build of the echoserver.