From 8a13a829df75375336aaa192683a237101bcc660 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Thu, 13 Sep 2018 17:19:39 -0700 Subject: [PATCH] scan-build fixes 1. Didn't initialize errFd before calling select() in wolffwd. 2. Wasn't checking the accepted appFd in wolffwd. 3. For the test_KDF() unit test, a call to ConvertHexToBin() could succeed and leave eKey NULL, and pass it to memcmp(). --- examples/wolffwd/wolffwd.c | 4 ++++ tests/unit.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/wolffwd/wolffwd.c b/examples/wolffwd/wolffwd.c index 55a5f28..18662bd 100644 --- a/examples/wolffwd/wolffwd.c +++ b/examples/wolffwd/wolffwd.c @@ -341,6 +341,8 @@ THREAD_RETURN WOLFSSH_THREAD wolffwd_worker(void* args) for (;;) { rxFds = templateFds; + errFds = templateFds; + to.tv_sec = 1; to.tv_usec = 0; ret = select(nFds, &rxFds, NULL, &errFds, &to); @@ -395,6 +397,8 @@ THREAD_RETURN WOLFSSH_THREAD wolffwd_worker(void* args) if (!appFdSet && FD_ISSET(listenFd, &rxFds)) { appFd = accept(listenFd, (struct sockaddr*)&fwdFromHostAddr, &fwdFromHostAddrSz); + if (appFd < 0) + break; FD_SET(appFd, &templateFds); nFds = appFd + 1; appFdSet = 1; diff --git a/tests/unit.c b/tests/unit.c index e43e0e6..3f29f8c 100644 --- a/tests/unit.c +++ b/tests/unit.c @@ -327,7 +327,7 @@ static int test_KDF(void) tv->h, &h, &hSz, tv->sessionId, &sId, &sIdSz, tv->expectedKey, &eKey, &eKeySz); - if (result != 0) { + if (result != 0 || eKey == NULL) { printf("KDF: Could not convert test vector %u.\n", i); return -100; }