Review Fixes

1. Add a wrapper to the key-gen code that checks for wolfCrypt's keygen flag and errors if keygen isn't available.
2. The main loops around wolfSSH_stream_read() for the example client and server needed to check the error register for WANT_READ or WANT_WRITE, not the return code.
pull/134/head
John Safranek 2019-02-27 11:06:05 -08:00
parent 3a2da4bb0e
commit 2350ffe00e
3 changed files with 11 additions and 1 deletions

View File

@ -304,6 +304,7 @@ THREAD_RETURN WOLFSSH_THREAD client_test(void* args)
do { do {
ret = wolfSSH_stream_read(ssh, (byte*)rxBuf, sizeof(rxBuf) - 1); ret = wolfSSH_stream_read(ssh, (byte*)rxBuf, sizeof(rxBuf) - 1);
if (ret <= 0) { if (ret <= 0) {
ret = wolfSSH_get_error(ssh);
if (ret != WS_WANT_READ && ret != WS_WANT_WRITE) if (ret != WS_WANT_READ && ret != WS_WANT_WRITE)
err_sys("Stream read failed."); err_sys("Stream read failed.");
} }

View File

@ -166,6 +166,8 @@ static THREAD_RETURN WOLFSSH_THREAD server_worker(void* vArgs)
rxSz = wolfSSH_stream_read(threadCtx->ssh, rxSz = wolfSSH_stream_read(threadCtx->ssh,
buf + backlogSz, buf + backlogSz,
EXAMPLE_BUFFER_SZ); EXAMPLE_BUFFER_SZ);
if (rxSz <= 0)
rxSz = wolfSSH_get_error(threadCtx->ssh);
} while (rxSz == WS_WANT_READ || rxSz == WS_WANT_WRITE); } while (rxSz == WS_WANT_READ || rxSz == WS_WANT_WRITE);
if (rxSz > 0) { if (rxSz > 0) {

View File

@ -44,6 +44,8 @@
#ifdef WOLFSSH_KEYGEN #ifdef WOLFSSH_KEYGEN
#ifdef WOLFSSL_KEY_GEN
#ifdef NO_INLINE #ifdef NO_INLINE
#include <wolfssh/misc.h> #include <wolfssh/misc.h>
#else #else
@ -105,4 +107,9 @@ int wolfSSH_MakeRsaKey(byte* out, word32 outSz,
return ret; return ret;
} }
#endif
#else /* WOLFSSL_KEY_GEN */
#error "wolfSSH keygen requires that keygen is enabled in wolfSSL, use --enable-keygen or #define WOLFSSL_KEY_GEN."
#endif /* WOLFSSL_KEY_GEN */
#endif /* WOLFSSH_KEYGEN */