Merge pull request #383 from ejohnstown/config-h

Fixes when compiling with an old version of GCC
pull/384/head
David Garske 2022-01-27 11:27:11 -08:00 committed by GitHub
commit 5347ff712b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 85 additions and 25 deletions

View File

@ -16,7 +16,7 @@ AM_INIT_AUTOMAKE([1.11 -Wall -Werror -Wno-portability foreign tar-ustar subdir-o
AC_ARG_PROGRAM
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([src/config.h])
AC_CONFIG_HEADERS([config.h])
WOLFSSH_LIBRARY_VERSION=12:3:3
# | | |
@ -84,6 +84,7 @@ CPPFLAGS="$CPPFLAGS -I${wcpath}/include"
AC_CHECK_LIB([wolfssl],[wolfCrypt_Init],,[AC_MSG_ERROR([libwolfssl is required for ${PACKAGE}. It can be obtained from https://www.wolfssl.com/download.html/ .])])
AC_CHECK_FUNCS([gethostbyname getaddrinfo gettimeofday inet_ntoa memset socket wc_ecc_set_rng])
AC_CHECK_DECLS([[pread],[pwrite]],,[unistd.h])
# DEBUG
DEBUG_CFLAGS="-g -O0"

View File

@ -18,6 +18,10 @@
* along with wolfSSH. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#define WOLFSSH_TEST_CLIENT
#include <wolfssh/ssh.h>
@ -537,14 +541,17 @@ static THREAD_RET readInput(void* in)
sz = (word32)ret;
#endif
if (ret <= 0) {
err_sys("Error reading stdin");
fprintf(stderr, "Error reading stdin\n");
return THREAD_RET_SUCCESS;
}
/* lock SSH structure access */
wc_LockMutex(&args->lock);
ret = wolfSSH_stream_send(args->ssh, buf, sz);
wc_UnLockMutex(&args->lock);
if (ret <= 0)
err_sys("Couldn't send data");
if (ret <= 0) {
fprintf(stderr, "Couldn't send data\n");
return THREAD_RET_SUCCESS;
}
}
#if defined(HAVE_ECC) && defined(FP_ECC) && defined(HAVE_THREAD_LS)
wc_ecc_fp_free(); /* free per thread cache */

View File

@ -18,13 +18,13 @@
* along with wolfSSH. If not, see <http://www.gnu.org/licenses/>.
*/
#define WOLFSSH_TEST_SERVER
#define WOLFSSH_TEST_ECHOSERVER
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#define WOLFSSH_TEST_SERVER
#define WOLFSSH_TEST_ECHOSERVER
#ifdef WOLFSSL_USER_SETTINGS
#include <wolfssl/wolfcrypt/settings.h>
#else

View File

@ -18,6 +18,10 @@
* along with wolfSSH. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#define WOLFSSH_TEST_CLIENT
#define WOLFSSH_TEST_SERVER

View File

@ -18,6 +18,10 @@
* along with wolfSSH. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#define WOLFSSH_TEST_CLIENT
#include <stdio.h>
@ -231,7 +235,7 @@ THREAD_RETURN WOLFSSH_THREAD scp_client(void* args)
word16 port = wolfSshPort;
byte nonBlock = 0;
enum copyDir dir = copyNone;
char ch;
int ch;
((func_args*)args)->return_code = 0;

View File

@ -18,6 +18,10 @@
* along with wolfSSH. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#define WOLFSSH_TEST_SERVER
#define WOLFSSH_TEST_THREADING

View File

@ -18,6 +18,10 @@
* along with wolfSSH. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#define WOLFSSH_TEST_CLIENT
#include <wolfssh/ssh.h>

View File

@ -2356,7 +2356,7 @@ static INLINE byte AeadModeForId(byte id)
static int DoKexInit(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
{
int ret = WS_SUCCESS;
int side;
int side = WOLFSSH_ENDPOINT_SERVER;
byte algoId;
byte list[16] = {ID_NONE};
word32 listSz;
@ -4475,7 +4475,7 @@ static int DoUserAuthRequestPublicKey(WOLFSSH* ssh, WS_UserAuthData* authData,
else {
wc_HashAlg hash;
byte digest[WC_MAX_DIGEST_SIZE];
word32 digestSz;
word32 digestSz = 0;
enum wc_HashType hashId = WC_HASH_TYPE_SHA;
byte pkTypeId;
@ -4489,10 +4489,16 @@ static int DoUserAuthRequestPublicKey(WOLFSSH* ssh, WS_UserAuthData* authData,
if (ret == WS_SUCCESS) {
hashId = HashForId(pkTypeId);
WMEMSET(digest, 0, sizeof(digest));
digestSz = wc_HashGetDigestSize(hashId);
ret = wc_HashInit(&hash, hashId);
ret = wc_HashGetDigestSize(hashId);
if (ret > 0) {
digestSz = ret;
ret = 0;
}
}
if (ret == 0)
ret = wc_HashInit(&hash, hashId);
if (ret == 0) {
c32toa(ssh->sessionIdSz, digest);
ret = wc_HashUpdate(&hash, hashId, digest, UINT32_SZ);

View File

@ -37,6 +37,13 @@
#include <stdio.h>
#endif
/*
Flags:
WOLFSSH_LOCAL_PREAD_PWRITE
Defined to use local implementations of pread() and pwrite(). Switched
on automatically if pread() or pwrite() aren't found by configure.
*/
#if !defined(NO_FILESYSTEM) && !defined(WOLFSSH_USER_FILESYSTEM)
int wfopen(WFILE** f, const char* filename, const char* mode)
@ -82,6 +89,16 @@ int wfopen(WFILE** f, const char* filename, const char* mode)
#endif
}
/* If either pread() or pwrite() are missing, use the local versions. */
#if (defined(USE_OSE_API) || \
!defined(HAVE_DECL_PREAD) || (HAVE_DECL_PREAD == 0) || \
!defined(HAVE_DECL_PWRITE) || (HAVE_DECL_PWRITE == 0))
#undef WOLFSSH_LOCAL_PREAD_PWRITE
#define WOLFSSH_LOCAL_PREAD_PWRITE
#endif
#if (defined(WOLFSSH_SFTP) || defined(WOLFSSH_SCP)) && \
!defined(NO_WOLFSSH_SERVER)
@ -90,7 +107,7 @@ int wfopen(WFILE** f, const char* filename, const char* mode)
/* This is current inline in the source. */
#elif defined(USE_OSE_API)
#elif defined(WOLFSSH_LOCAL_PREAD_PWRITE)
int wPwrite(WFD fd, unsigned char* buf, unsigned int sz,
const unsigned int* shortOffset)
@ -104,7 +121,6 @@ int wfopen(WFILE** f, const char* filename, const char* mode)
return ret;
}
int wPread(WFD fd, unsigned char* buf, unsigned int sz,
const unsigned int* shortOffset)
{
@ -117,7 +133,7 @@ int wfopen(WFILE** f, const char* filename, const char* mode)
return ret;
}
#else /* USE_WINDOWS_API USE_OSE_API */
#else /* USE_WINDOWS_API WOLFSSH_LOCAL_PREAD_PWRITE */
int wPwrite(WFD fd, unsigned char* buf, unsigned int sz,
const unsigned int* shortOffset)

View File

@ -954,7 +954,7 @@ static INLINE int SFTP_GetSz(byte* buf, word32* sz,
#ifndef WOLFSSH_USER_FILESYSTEM
static int SFTP_GetAttributes(void* fs, const char* fileName,
WS_SFTP_FILEATRB* atr, byte link, void* heap);
WS_SFTP_FILEATRB* atr, byte noFollow, void* heap);
static int SFTP_GetAttributes_Handle(WOLFSSH* ssh, byte* handle, int handleSz,
WS_SFTP_FILEATRB* atr);
#endif
@ -4098,7 +4098,7 @@ static word32 TimeTo32(word16 d, word16 t)
* returns WS_SUCCESS on success
*/
int SFTP_GetAttributes(void* fs, const char* fileName, WS_SFTP_FILEATRB* atr,
byte link, void* heap)
byte noFollow, void* heap)
{
DSTAT stats;
int sz = (int)WSTRLEN(fileName);
@ -4107,7 +4107,7 @@ int SFTP_GetAttributes(void* fs, const char* fileName, WS_SFTP_FILEATRB* atr,
(void)heap;
(void)fs;
if (link) {
if (noFollow) {
ret = WLSTAT(fileName, &stats);
}
else {
@ -4238,13 +4238,13 @@ int SFTP_GetAttributes_Handle(WOLFSSH* ssh, byte* handle, int handleSz,
* returns WS_SUCCESS on success
*/
int SFTP_GetAttributes(void* fs, const char* fileName, WS_SFTP_FILEATRB* atr,
byte link, void* heap)
byte noFollow, void* heap)
{
BOOL error;
WIN32_FILE_ATTRIBUTE_DATA stats;
WLOG(WS_LOG_SFTP, "Entering SFTP_GetAttributes()");
(void)link;
(void)noFollow;
(void)fs;
/* @TODO add proper Windows link support */
@ -4283,7 +4283,7 @@ int SFTP_GetAttributes(void* fs, const char* fileName, WS_SFTP_FILEATRB* atr,
* Fills out a WS_SFTP_FILEATRB structure
* returns WS_SUCCESS on success */
int SFTP_GetAttributes(void* fs, const char* fileName, WS_SFTP_FILEATRB* atr,
byte link, void* heap)
byte noFollow, void* heap)
{
int err, sz;
MQX_FILE_PTR mfs_ptr;
@ -4401,7 +4401,7 @@ int SFTP_GetAttributes_Handle(WOLFSSH* ssh, byte* handle, int handleSz,
/* FatFs has its own structure for file attributes */
static int SFTP_GetAttributes(void* fs, const char* fileName,
WS_SFTP_FILEATRB* atr, byte link, void* heap)
WS_SFTP_FILEATRB* atr, byte noFollow, void* heap)
{
FILINFO info;
FRESULT ret;
@ -4522,14 +4522,14 @@ static int SFTP_GetAttributes_Handle(WOLFSSH* ssh, byte* handle, int handleSz,
* returns WS_SUCCESS on success
*/
int SFTP_GetAttributes(void* fs, const char* fileName, WS_SFTP_FILEATRB* atr,
byte link, void* heap)
byte noFollow, void* heap)
{
WSTAT_T stats;
(void)heap;
(void)fs;
if (link) {
if (noFollow) {
/* Note, for windows, we treat WSTAT and WLSTAT the same. */
if (WLSTAT(fileName, &stats) != 0) {
return WS_BAD_FILE_E;
@ -4620,7 +4620,7 @@ int wolfSSH_SFTP_RecvFSTAT(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
{
WS_SFTP_FILEATRB atr;
word32 handleSz;
word32 sz;
word32 sz = 0;
byte* handle;
word32 idx = 0;
int ret = WS_SUCCESS;

View File

@ -18,6 +18,9 @@
* along with wolfSSH. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <wolfssh/ssh.h>

View File

@ -18,6 +18,10 @@
* along with wolfSSH. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <wolfssh/ssh.h>
#include <wolfssh/wolfsftp.h>

View File

@ -18,6 +18,10 @@
* along with wolfSSH. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#define WOLFSSH_TEST_CLIENT
#define WOLFSSH_TEST_SERVER
#define WOLFSSH_TEST_THREADING

View File

@ -18,6 +18,9 @@
* along with wolfSSH. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <wolfssh/ssh.h>