From 0458d83137a574b607a6cc8dd948e224c3a9b940 Mon Sep 17 00:00:00 2001 From: Paul Adelsbach Date: Wed, 4 Mar 2026 15:29:36 -0800 Subject: [PATCH] Fix multibyte passwords, file mode and attrib reporting --- apps/wolfsshd/auth.c | 2 +- src/wolfscp.c | 4 ++-- src/wolfsftp.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/wolfsshd/auth.c b/apps/wolfsshd/auth.c index 03b15abe6..2e2ac3fae 100644 --- a/apps/wolfsshd/auth.c +++ b/apps/wolfsshd/auth.c @@ -815,7 +815,7 @@ static int CheckPasswordWIN(const char* usr, const byte* pw, word32 pwSz, WOLFSS } if (ret == WSSHD_AUTH_SUCCESS) { - if (MultiByteToWideChar(CP_UTF8, 0, pw, pwSz, pwW, pwWSz) != pwSz) { + if (MultiByteToWideChar(CP_UTF8, 0, pw, pwSz, pwW, pwWSz) != pwWSz) { ret = WSSHD_AUTH_FAILURE; } else { diff --git a/src/wolfscp.c b/src/wolfscp.c index f170444f4..b84904647 100644 --- a/src/wolfscp.c +++ b/src/wolfscp.c @@ -2253,9 +2253,9 @@ static int GetFileStats(void *fs, ScpSendCtx* ctx, const char* fileName, *fileMode = 0755; /* Mimic S_IFMT */ if (ctx->s.type == FS_DIR_ENTRY_FILE) - *fileMode |= 0040000; + *fileMode |= 0100000; /* S_IFREG */ else if (ctx->s.type == FS_DIR_ENTRY_DIR) - *fileMode |= 0100000; + *fileMode |= 0040000; /* S_IFDIR */ else ret = WS_BAD_FILE_E; diff --git a/src/wolfsftp.c b/src/wolfsftp.c index 90b31c944..7cd90ecab 100644 --- a/src/wolfsftp.c +++ b/src/wolfsftp.c @@ -4709,7 +4709,7 @@ int SFTP_GetAttributes(void* fs, const char* fileName, WS_SFTP_FILEATRB* atr, atr->flags |= WOLFSSH_FILEATRB_PERM; atr->per = 0555 | - ((stats.dwFileAttributes | FILE_ATTRIBUTE_READONLY) ? 0 : 0200); + ((stats.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? 0 : 0200); atr->per |= ((stats.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? FILEATRB_PER_DIR : FILEATRB_PER_FILE);