Skip to content

Commit b3f5fd9

Browse files
Fix minor issues
1 parent ee59f31 commit b3f5fd9

3 files changed

Lines changed: 12 additions & 10 deletions

File tree

apps/wolfssh/common.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,9 @@ static int FingerprintKey(const byte* pubKey, word32 pubKeySz, char* out)
225225
ret = Base64_Encode_NoNl(digest, sizeof(digest), (byte*)fp, &fpSz);
226226

227227
if (ret == 0) {
228-
if (fp[fpSz] == '=') {
229-
fp[fpSz] = 0;
228+
if (fpSz > 0 && fp[fpSz - 1] == '=') {
229+
/* Remove trailing padding */
230+
fp[fpSz - 1] = 0;
230231
}
231232

232233
WSTRCAT(out, "SHA256:");

src/internal.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4235,7 +4235,7 @@ static word32 AlgoListSz(const char* algoList)
42354235
return 0;
42364236

42374237
algoListSz = (word32)WSTRLEN(algoList);
4238-
if (algoList[algoListSz-1] == ',') {
4238+
if (algoListSz > 0 && algoList[algoListSz-1] == ',') {
42394239
--algoListSz;
42404240
}
42414241

@@ -8573,11 +8573,10 @@ static int DoUserAuthInfoRequest(WOLFSSH* ssh, byte* buf, word32 len,
85738573
if (ssh == NULL || buf == NULL || len == 0 || idx == NULL)
85748574
ret = WS_BAD_ARGUMENT;
85758575

8576-
if (ssh->ctx != NULL) {
8577-
heap = ssh->ctx->heap;
8578-
}
8579-
85808576
if (ret == WS_SUCCESS) {
8577+
if (ssh->ctx != NULL) {
8578+
heap = ssh->ctx->heap;
8579+
}
85818580
begin = *idx;
85828581
ret = GetStringAlloc(heap, (char**)&authName, NULL, buf, len, &begin);
85838582
}
@@ -8653,7 +8652,9 @@ static int DoUserAuthInfoRequest(WOLFSSH* ssh, byte* buf, word32 len,
86538652
ret = SendUserAuthKeyboardResponse(ssh);
86548653
}
86558654

8656-
ssh->authId = ID_USERAUTH_KEYBOARD;
8655+
if (ret == WS_SUCCESS) {
8656+
ssh->authId = ID_USERAUTH_KEYBOARD;
8657+
}
86578658

86588659
WLOG(WS_LOG_DEBUG, "Leaving DoUserAuthInfoRequest(), ret = %d", ret);
86598660

@@ -10948,11 +10949,11 @@ static int BundlePacket(WOLFSSH* ssh)
1094810949

1094910950
idx += paddingSz;
1095010951

10951-
WMEMSET(output + idx, 0, macSz);
1095210952
if (idx + macSz > ssh->outputBuffer.bufferSz) {
1095310953
ret = WS_BUFFER_E;
1095410954
}
1095510955
else {
10956+
WMEMSET(output + idx, 0, macSz);
1095610957
ret = CreateMac(ssh, ssh->outputBuffer.buffer +
1095710958
ssh->packetStartIdx, ssh->outputBuffer.length -
1095810959
ssh->packetStartIdx + paddingSz, output + idx);

src/ssh.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2092,7 +2092,7 @@ int wolfSSH_ReadKey_file(const char* name,
20922092
out, outSz, outType, outTypeSz, *isPrivate, heap);
20932093
}
20942094

2095-
WFCLOSE(ssh->fs, file);
2095+
WFCLOSE(NULL, file);
20962096
WFREE(in, heap, DYNTYPE_FILE);
20972097

20982098
return ret;

0 commit comments

Comments
 (0)