Skip to content

Commit d2eeec5

Browse files
Fix minor issues
1 parent 157cb01 commit d2eeec5

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

src/internal.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4880,16 +4880,14 @@ static int ParseRSAPubKey(WOLFSSH *ssh,
48804880
byte* n;
48814881
word32 nSz;
48824882
word32 pubKeyIdx = 0;
4883-
word32 scratch;
48844883

48854884
ret = wc_InitRsaKey(&sigKeyBlock_ptr->sk.rsa.key, ssh->ctx->heap);
48864885
if (ret != 0)
48874886
ret = WS_RSA_E;
4888-
if (ret == 0)
4889-
ret = GetUint32(&scratch, pubKey, pubKeySz, &pubKeyIdx);
4890-
/* This is the algo name. */
4887+
/* Skip the algo name. */
4888+
if (ret == WS_SUCCESS)
4889+
ret = GetSkip(pubKey, pubKeySz, &pubKeyIdx);
48914890
if (ret == WS_SUCCESS) {
4892-
pubKeyIdx += scratch;
48934891
ret = GetUint32(&eSz, pubKey, pubKeySz, &pubKeyIdx);
48944892
if (ret == WS_SUCCESS && eSz > pubKeySz - pubKeyIdx)
48954893
ret = WS_BUFFER_E;
@@ -4932,7 +4930,6 @@ static int ParseECCPubKey(WOLFSSH *ssh,
49324930
const byte* q;
49334931
word32 qSz, pubKeyIdx = 0;
49344932
int primeId = 0;
4935-
word32 scratch;
49364933

49374934
ret = wc_ecc_init_ex(&sigKeyBlock_ptr->sk.ecc.key, ssh->ctx->heap,
49384935
INVALID_DEVID);
@@ -4958,12 +4955,10 @@ static int ParseECCPubKey(WOLFSSH *ssh,
49584955

49594956
/* Skip the curve name since we're getting it from the algo. */
49604957
if (ret == WS_SUCCESS)
4961-
ret = GetUint32(&scratch, pubKey, pubKeySz, &pubKeyIdx);
4958+
ret = GetSkip(pubKey, pubKeySz, &pubKeyIdx);
49624959

4963-
if (ret == WS_SUCCESS) {
4964-
pubKeyIdx += scratch;
4960+
if (ret == WS_SUCCESS)
49654961
ret = GetStringRef(&qSz, &q, pubKey, pubKeySz, &pubKeyIdx);
4966-
}
49674962

49684963
if (ret == WS_SUCCESS) {
49694964
ret = wc_ecc_import_x963_ex(q, qSz,
@@ -9407,7 +9402,7 @@ static int DoChannelFailure(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
94079402

94089403
WLOG(WS_LOG_DEBUG, "Entering DoChannelFailure()");
94099404

9410-
if (ssh == NULL || buf == NULL || len != 0 || idx == NULL)
9405+
if (ssh == NULL || buf == NULL || len == 0 || idx == NULL)
94119406
ret = WS_BAD_ARGUMENT;
94129407

94139408
if (ret == WS_SUCCESS)

src/port.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ void* WS_CreateFileA(const char* fileName, unsigned long desiredAccess,
267267
void* WS_FindFirstFileA(const char* fileName,
268268
char* realFileName, size_t realFileNameSz, int* isDir, void* heap)
269269
{
270-
HANDLE findHandle = NULL;
270+
HANDLE findHandle = INVALID_HANDLE_VALUE;
271271
WIN32_FIND_DATAW findFileData;
272272
wchar_t* unicodeFileName;
273273
size_t unicodeFileNameSz = 0;
@@ -295,12 +295,14 @@ void* WS_FindFirstFileA(const char* fileName,
295295

296296
WFREE(unicodeFileName, heap, PORT_DYNTYPE_STRING);
297297

298-
error = wcstombs_s(NULL, realFileName, realFileNameSz,
299-
findFileData.cFileName, realFileNameSz);
298+
if (findHandle != INVALID_HANDLE_VALUE) {
299+
error = wcstombs_s(NULL, realFileName, realFileNameSz,
300+
findFileData.cFileName, realFileNameSz);
300301

301-
if (isDir != NULL) {
302-
*isDir =
303-
(findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
302+
if (isDir != NULL) {
303+
*isDir =
304+
(findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
305+
}
304306
}
305307

306308
return (void*)findHandle;

src/wolfterm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static void doDisplayAttributes(WOLFSSH* ssh, WOLFSSH_HANDLE handle, word32* arg
181181
break;
182182

183183
case 30: /* set black foreground */
184-
SetConsoleTextAttribute(handle, (atr & ~(WS_MASK_RBGBG)));
184+
SetConsoleTextAttribute(handle, (atr & ~(WS_MASK_RBGFG)));
185185
break;
186186

187187
case 31: /* red foreground */

0 commit comments

Comments
 (0)