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().
pull/98/head
John Safranek 2018-09-13 17:19:39 -07:00
parent f8f3d125b6
commit 8a13a829df
2 changed files with 5 additions and 1 deletions

View File

@ -341,6 +341,8 @@ THREAD_RETURN WOLFSSH_THREAD wolffwd_worker(void* args)
for (;;) { for (;;) {
rxFds = templateFds; rxFds = templateFds;
errFds = templateFds;
to.tv_sec = 1; to.tv_sec = 1;
to.tv_usec = 0; to.tv_usec = 0;
ret = select(nFds, &rxFds, NULL, &errFds, &to); 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)) { if (!appFdSet && FD_ISSET(listenFd, &rxFds)) {
appFd = accept(listenFd, appFd = accept(listenFd,
(struct sockaddr*)&fwdFromHostAddr, &fwdFromHostAddrSz); (struct sockaddr*)&fwdFromHostAddr, &fwdFromHostAddrSz);
if (appFd < 0)
break;
FD_SET(appFd, &templateFds); FD_SET(appFd, &templateFds);
nFds = appFd + 1; nFds = appFd + 1;
appFdSet = 1; appFdSet = 1;

View File

@ -327,7 +327,7 @@ static int test_KDF(void)
tv->h, &h, &hSz, tv->h, &h, &hSz,
tv->sessionId, &sId, &sIdSz, tv->sessionId, &sId, &sIdSz,
tv->expectedKey, &eKey, &eKeySz); tv->expectedKey, &eKey, &eKeySz);
if (result != 0) { if (result != 0 || eKey == NULL) {
printf("KDF: Could not convert test vector %u.\n", i); printf("KDF: Could not convert test vector %u.\n", i);
return -100; return -100;
} }