Skip to content

Commit

Permalink
PR review: Update some std-C functions with the proper porting wrappers.
Browse files Browse the repository at this point in the history
  • Loading branch information
ejohnstown committed Nov 2, 2023
1 parent ca6c50d commit a65c411
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,7 @@ static int wolfSSH_KEY_init(WS_KeySignature* key, byte keyId, void* heap)
int ret = WS_SUCCESS;

if (key != NULL) {
WMEMSET(key, 0, sizeof(*key));
key->keySigId = keyId;

switch (keyId) {
Expand Down Expand Up @@ -1103,12 +1104,12 @@ static int GetOpenSshKey(WS_KeySignature *key,
word32 keyCount = 0, strSz = 0, i;
int ret = WS_SUCCESS;

if (strcmp(AuthMagic, (const char*)buf) != 0) {
if (WSTRCMP(AuthMagic, (const char*)buf) != 0) {
ret = WS_KEY_AUTH_MAGIC_E;
}

if (ret == WS_SUCCESS) {
*idx += (word32)strlen(AuthMagic) + 1;
*idx += (word32)WSTRLEN(AuthMagic) + 1;
ret = GetSkip(buf, len, idx); /* ciphername */
}

Expand Down Expand Up @@ -9137,7 +9138,7 @@ static int SendKexGetSigningKey(WOLFSSH* ssh,
sigKeyBlock_ptr->sk.ecc.primeName =
PrimeNameForId(ssh->handshake->pubKeyId);
sigKeyBlock_ptr->sk.ecc.primeNameSz =
(word32)strlen(sigKeyBlock_ptr->sk.ecc.primeName);
(word32)WSTRLEN(sigKeyBlock_ptr->sk.ecc.primeName);

/* Decode the user-configured ECDSA private key. */
sigKeyBlock_ptr->sk.ecc.qSz =
Expand Down Expand Up @@ -9427,7 +9428,7 @@ int SendKexDhReply(WOLFSSH* ssh)
sigKeyBlock_ptr->pubKeyName =
IdToName(SigTypeForId(sigKeyBlock_ptr->pubKeyId));
sigKeyBlock_ptr->pubKeyNameSz =
(word32)strlen(sigKeyBlock_ptr->pubKeyName);
(word32)WSTRLEN(sigKeyBlock_ptr->pubKeyName);
sigKeyBlock_ptr->pubKeyFmtId = sigKeyBlock_ptr->pubKeyId;
if (sigKeyBlock_ptr->pubKeyId == ID_RSA_SHA2_256
|| sigKeyBlock_ptr->pubKeyId == ID_RSA_SHA2_512) {
Expand All @@ -9436,7 +9437,7 @@ int SendKexDhReply(WOLFSSH* ssh)
sigKeyBlock_ptr->pubKeyFmtName =
IdToName(sigKeyBlock_ptr->pubKeyFmtId);
sigKeyBlock_ptr->pubKeyFmtNameSz =
(word32)strlen(sigKeyBlock_ptr->pubKeyFmtName);
(word32)WSTRLEN(sigKeyBlock_ptr->pubKeyFmtName);

switch (ssh->handshake->kexId) {
#ifndef WOLFSSH_NO_ECDH_SHA2_NISTP256
Expand Down
4 changes: 2 additions & 2 deletions src/ssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1654,8 +1654,8 @@ static int DoOpenSshKey(const byte* in, word32 inSz, byte** out,
newKey = *out;
}

in += strlen(PrivBeginOpenSSH);
inSz -= (word32)(strlen(PrivBeginOpenSSH) + strlen(PrivEndOpenSSH) + 2);
in += WSTRLEN(PrivBeginOpenSSH);
inSz -= (word32)(WSTRLEN(PrivBeginOpenSSH) + WSTRLEN(PrivEndOpenSSH) + 2);

ret = Base64_Decode((byte*)in, inSz, newKey, &newKeySz);
if (ret == 0) {
Expand Down

0 comments on commit a65c411

Please sign in to comment.