Skip to content

Commit d42230d

Browse files
authored
Merge pull request #444 from JacobBarthelmeh/release
fix for include with FIPS build and cast with g++ build
2 parents ed751da + 20ace73 commit d42230d

File tree

8 files changed

+23
-8
lines changed

8 files changed

+23
-8
lines changed

apps/wolfsshd/auth.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626

2727
#ifdef __linux__
2828
#define _XOPEN_SOURCE
29-
#define _GNU_SOURCE
29+
#ifndef _GNU_SOURCE
30+
#define _GNU_SOURCE
31+
#endif
3032
#endif
3133
#include <unistd.h>
3234

apps/wolfsshd/configuration.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ static int HandleInclude(WOLFSSHD_CONFIG *conf, const char *value)
479479
struct dirent *dir;
480480
DIR *d;
481481
char *path;
482-
char *filepath = WMALLOC(PATH_MAX, NULL, 0);
482+
char *filepath = (char*)WMALLOC(PATH_MAX, NULL, 0);
483483

484484
/* Back find the full path */
485485
while (ptr2 != value) {
@@ -490,13 +490,13 @@ static int HandleInclude(WOLFSSHD_CONFIG *conf, const char *value)
490490
}
491491

492492
if (ptr2 != value) {
493-
path = WMALLOC(ptr2 - value + 1, NULL, 0);
493+
path = (char*)WMALLOC(ptr2 - value + 1, NULL, 0);
494494
memcpy(path, value, ptr2 - value);
495495
path[ptr2 - value] = '\0';
496496
prefix = ptr2 + 1;
497497
prefixLen = (int)(ptr - ptr2 - 1);
498498
} else {
499-
path = WMALLOC(2, NULL, 0);
499+
path = (char*)WMALLOC(2, NULL, 0);
500500
memcpy(path, ".", 1);
501501
path[1] = '\0';
502502
prefix = value;

apps/wolfsshd/wolfsshd.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,11 @@ int main(int argc, char** argv)
780780

781781
case 'p':
782782
if (ret == WS_SUCCESS) {
783+
if (myoptarg == NULL) {
784+
ret = WS_BAD_ARGUMENT;
785+
break;
786+
}
787+
783788
ret = XATOI(myoptarg);
784789
if (ret < 0) {
785790
fprintf(stderr, "Issue parsing port number %s\n",

examples/echoserver/echoserver.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ static int ssh_worker(thread_ctx_t* threadCtx)
747747
if (agentListenFd > maxFd)
748748
maxFd = agentListenFd;
749749
}
750-
if (threadCtx->agentCbCtx.state == AGENT_STATE_CONNECTED) {
750+
if (agentFd >= 0 && threadCtx->agentCbCtx.state == AGENT_STATE_CONNECTED) {
751751
FD_SET(agentFd, &readFds);
752752
if (agentFd > maxFd)
753753
maxFd = agentFd;
@@ -759,7 +759,7 @@ static int ssh_worker(thread_ctx_t* threadCtx)
759759
if (fwdListenFd > maxFd)
760760
maxFd = fwdListenFd;
761761
}
762-
if (threadCtx->fwdCbCtx.state == FWD_STATE_CONNECTED) {
762+
if (fwdFd >= 0 && threadCtx->fwdCbCtx.state == FWD_STATE_CONNECTED) {
763763
FD_SET(fwdFd, &readFds);
764764
if (fwdFd > maxFd)
765765
maxFd = fwdFd;
@@ -918,7 +918,7 @@ static int ssh_worker(thread_ctx_t* threadCtx)
918918
}
919919
#endif
920920
#ifdef WOLFSSH_AGENT
921-
if (threadCtx->agentCbCtx.state == AGENT_STATE_CONNECTED) {
921+
if (agentFd >= 0 && threadCtx->agentCbCtx.state == AGENT_STATE_CONNECTED) {
922922
if (FD_ISSET(agentFd, &readFds)) {
923923
#ifdef SHELL_DEBUG
924924
printf("agentFd set in readfd\n");
@@ -979,7 +979,7 @@ static int ssh_worker(thread_ctx_t* threadCtx)
979979
}
980980
#endif
981981
#ifdef WOLFSSH_FWD
982-
if (threadCtx->fwdCbCtx.state == FWD_STATE_CONNECTED) {
982+
if (fwdFd >= 0 && threadCtx->fwdCbCtx.state == FWD_STATE_CONNECTED) {
983983
if (FD_ISSET(fwdFd, &readFds)) {
984984
#ifdef SHELL_DEBUG
985985
printf("fwdFd set in readfd\n");

examples/portfwd/portfwd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ THREAD_RETURN WOLFSSH_THREAD portfwd_worker(void* args)
271271
break;
272272

273273
case 'p':
274+
if (myoptarg == NULL)
275+
err_sys("null argument found");
274276
port = (word16)atoi(myoptarg);
275277
#if !defined(NO_MAIN_DRIVER) || defined(USE_WINDOWS_API)
276278
if (port == 0)

examples/scpclient/scpclient.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@ THREAD_RETURN WOLFSSH_THREAD scp_client(void* args)
277277
break;
278278

279279
case 'p':
280+
if (myoptarg == NULL)
281+
err_sys("null argument found");
282+
280283
port = (word16)atoi(myoptarg);
281284
#if !defined(NO_MAIN_DRIVER) || defined(USE_WINDOWS_API)
282285
if (port == 0)

examples/sftpclient/sftpclient.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,8 @@ THREAD_RETURN WOLFSSH_THREAD sftpclient_test(void* args)
13611361
break;
13621362

13631363
case 'p':
1364+
if (myoptarg == NULL)
1365+
err_sys("null argument found");
13641366
port = (word16)atoi(myoptarg);
13651367
#if !defined(NO_MAIN_DRIVER) || defined(USE_WINDOWS_API)
13661368
if (port == 0)

src/ssh.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#endif
4444

4545
#ifdef HAVE_FIPS
46+
#include <wolfssl/wolfcrypt/fips_test.h>
4647
static void myFipsCb(int ok, int err, const char* hash)
4748
{
4849
printf("in my Fips callback, ok = %d, err = %d\n", ok, err);

0 commit comments

Comments
 (0)