Fix minor issues

pull/899/head
Yosuke Shimizu 2026-03-24 11:16:16 +09:00
parent 157cb01f4b
commit d2eeec5e26
3 changed files with 15 additions and 18 deletions

View File

@ -4880,16 +4880,14 @@ static int ParseRSAPubKey(WOLFSSH *ssh,
byte* n;
word32 nSz;
word32 pubKeyIdx = 0;
word32 scratch;
ret = wc_InitRsaKey(&sigKeyBlock_ptr->sk.rsa.key, ssh->ctx->heap);
if (ret != 0)
ret = WS_RSA_E;
if (ret == 0)
ret = GetUint32(&scratch, pubKey, pubKeySz, &pubKeyIdx);
/* This is the algo name. */
/* Skip the algo name. */
if (ret == WS_SUCCESS)
ret = GetSkip(pubKey, pubKeySz, &pubKeyIdx);
if (ret == WS_SUCCESS) {
pubKeyIdx += scratch;
ret = GetUint32(&eSz, pubKey, pubKeySz, &pubKeyIdx);
if (ret == WS_SUCCESS && eSz > pubKeySz - pubKeyIdx)
ret = WS_BUFFER_E;
@ -4932,7 +4930,6 @@ static int ParseECCPubKey(WOLFSSH *ssh,
const byte* q;
word32 qSz, pubKeyIdx = 0;
int primeId = 0;
word32 scratch;
ret = wc_ecc_init_ex(&sigKeyBlock_ptr->sk.ecc.key, ssh->ctx->heap,
INVALID_DEVID);
@ -4958,12 +4955,10 @@ static int ParseECCPubKey(WOLFSSH *ssh,
/* Skip the curve name since we're getting it from the algo. */
if (ret == WS_SUCCESS)
ret = GetUint32(&scratch, pubKey, pubKeySz, &pubKeyIdx);
ret = GetSkip(pubKey, pubKeySz, &pubKeyIdx);
if (ret == WS_SUCCESS) {
pubKeyIdx += scratch;
if (ret == WS_SUCCESS)
ret = GetStringRef(&qSz, &q, pubKey, pubKeySz, &pubKeyIdx);
}
if (ret == WS_SUCCESS) {
ret = wc_ecc_import_x963_ex(q, qSz,
@ -9407,7 +9402,7 @@ static int DoChannelFailure(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
WLOG(WS_LOG_DEBUG, "Entering DoChannelFailure()");
if (ssh == NULL || buf == NULL || len != 0 || idx == NULL)
if (ssh == NULL || buf == NULL || len == 0 || idx == NULL)
ret = WS_BAD_ARGUMENT;
if (ret == WS_SUCCESS)

View File

@ -267,7 +267,7 @@ void* WS_CreateFileA(const char* fileName, unsigned long desiredAccess,
void* WS_FindFirstFileA(const char* fileName,
char* realFileName, size_t realFileNameSz, int* isDir, void* heap)
{
HANDLE findHandle = NULL;
HANDLE findHandle = INVALID_HANDLE_VALUE;
WIN32_FIND_DATAW findFileData;
wchar_t* unicodeFileName;
size_t unicodeFileNameSz = 0;
@ -295,12 +295,14 @@ void* WS_FindFirstFileA(const char* fileName,
WFREE(unicodeFileName, heap, PORT_DYNTYPE_STRING);
error = wcstombs_s(NULL, realFileName, realFileNameSz,
findFileData.cFileName, realFileNameSz);
if (findHandle != INVALID_HANDLE_VALUE) {
error = wcstombs_s(NULL, realFileName, realFileNameSz,
findFileData.cFileName, realFileNameSz);
if (isDir != NULL) {
*isDir =
(findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
if (isDir != NULL) {
*isDir =
(findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
}
}
return (void*)findHandle;

View File

@ -181,7 +181,7 @@ static void doDisplayAttributes(WOLFSSH* ssh, WOLFSSH_HANDLE handle, word32* arg
break;
case 30: /* set black foreground */
SetConsoleTextAttribute(handle, (atr & ~(WS_MASK_RBGBG)));
SetConsoleTextAttribute(handle, (atr & ~(WS_MASK_RBGFG)));
break;
case 31: /* red foreground */