Merge pull request #881 from ejohnstown/static-fixes

Static analysis fixes
pull/884/head
JacobBarthelmeh 2026-02-25 17:05:13 -07:00 committed by GitHub
commit a2e6556a1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 10 deletions

View File

@ -413,7 +413,7 @@ static int CheckPasswordUnix(const char* usr, const byte* pw, word32 pwSz, WOLFS
}
if (ret == WS_SUCCESS) {
storedHashCpy = WSTRDUP(storedHash, NULL, DYNTYPE_STRING);
if (storedHash == NULL) {
if (storedHashCpy == NULL) {
wolfSSH_Log(WS_LOG_ERROR,
"[SSHD] Error getting stored hash copy");
ret = WS_MEMORY_E;

View File

@ -316,7 +316,7 @@ static int SetupCTX(WOLFSSHD_CONFIG* conf, WOLFSSH_CTX** ctx,
/* create a new WOLFSSH_CTX */
*ctx = wolfSSH_CTX_new(WOLFSSH_ENDPOINT_SERVER, NULL);
if (ctx == NULL) {
if (*ctx == NULL) {
wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Couldn't allocate SSH CTX data.");
ret = WS_MEMORY_E;
}

View File

@ -30,6 +30,7 @@
#endif
#include <stdio.h>
#include <stdint.h>
#include <wolfssh/ssh.h>
#include <wolfssh/internal.h>
#include <wolfssh/log.h>
@ -9469,11 +9470,15 @@ static int DoChannelWindowAdjust(WOLFSSH* ssh,
WLOG(WS_LOG_INFO, " peerWindowSz = %u",
channel->peerWindowSz);
channel->peerWindowSz += bytesToAdd;
WLOG(WS_LOG_INFO, " update peerWindowSz = %u",
channel->peerWindowSz);
if (bytesToAdd > UINT32_MAX - channel->peerWindowSz) {
ret = WS_OVERFLOW_E;
WLOG(WS_LOG_DEBUG, "peer window adjust would overflow");
}
else {
channel->peerWindowSz += bytesToAdd;
WLOG(WS_LOG_INFO, " update peerWindowSz = %u",
channel->peerWindowSz);
}
}
}

View File

@ -1423,9 +1423,10 @@ int ReceiveScpMessage(WOLFSSH* ssh)
if (err == 0) {
WOLFSSH_CHANNEL* channel;
channel = wolfSSH_ChannelFind(ssh, lastChannel, WS_CHANNEL_ID_SELF);
if (channel == NULL)
if (channel == NULL) {
ret = WS_INVALID_CHANID;
if (wolfSSH_ChannelGetEof(channel)) {
}
else if (wolfSSH_ChannelGetEof(channel)) {
return WS_EOF;
}
}
@ -2217,7 +2218,7 @@ static int GetFileStats(void *fs, ScpSendCtx* ctx, const char* fileName,
(word64)ctx->s.ftLastWriteTime.dwLowDateTime;
*fileMode = 0555 |
(ctx->s.dwFileAttributes | FILE_ATTRIBUTE_READONLY ? 0 : 0200);
(ctx->s.dwFileAttributes & FILE_ATTRIBUTE_READONLY ? 0 : 0200);
*fileMode |= (ctx->s.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? 0x4000 : 0;
#else
if (WSTAT(fs, fileName, &ctx->s) < 0) {