Files
ESP32_Serial_Swiss_Army_Knife/tests/wolfssh_parser_contract/pr899.patch
T
Commander1024 51f835c22f Harden SSH parsing and add notice tooling
- Enforce exact service and channel names with bounded failure parsing
- Add hash-pinned offline notice assembly and regression coverage
- Record advisory dispositions, provenance, integration evidence, and
  remaining gates
2026-09-16 15:06:38 +02:00

114 lines
4.0 KiB
Diff

From d2eeec5e263a4821c90805963eeb0666e99868a6 Mon Sep 17 00:00:00 2001
From: Yosuke Shimizu <yosuke@wolfssl.com>
Date: Tue, 24 Mar 2026 11:16:16 +0900
Subject: [PATCH] Fix minor issues
---
src/internal.c | 17 ++++++-----------
src/port.c | 14 ++++++++------
src/wolfterm.c | 2 +-
3 files changed, 15 insertions(+), 18 deletions(-)
diff --git a/src/internal.c b/src/internal.c
index 77f165dbb..8dc13dab6 100644
--- a/src/internal.c
+++ b/src/internal.c
@@ -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)
diff --git a/src/port.c b/src/port.c
index 37ee3ffc7..79546e890 100644
--- a/src/port.c
+++ b/src/port.c
@@ -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;
diff --git a/src/wolfterm.c b/src/wolfterm.c
index 63e69d679..e7abe907e 100644
--- a/src/wolfterm.c
+++ b/src/wolfterm.c
@@ -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 */