Skip to content

Commit 7d48298

Browse files
Merge pull request #863 from ejohnstown/release-1.4.22-2
Release v1.4.22
2 parents fb54473 + 7f6b5b3 commit 7d48298

File tree

1 file changed

+35
-17
lines changed

1 file changed

+35
-17
lines changed

src/internal.c

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2827,6 +2827,9 @@ byte NameToId(const char* name, word32 nameSz)
28272827
byte id = ID_UNKNOWN;
28282828
word32 i;
28292829

2830+
if (name == NULL)
2831+
return id;
2832+
28302833
for (i = 0; i < (sizeof(NameIdMap)/sizeof(NameIdPair)); i++) {
28312834
if (nameSz == (word32)WSTRLEN(NameIdMap[i].name) &&
28322835
XMEMCMP(name, NameIdMap[i].name, nameSz) == 0) {
@@ -3582,14 +3585,20 @@ int GetMpint(word32* mpintSz, const byte** mpint,
35823585
* the provided buffer, and terminates it with a NULL. */
35833586
int GetString(char* s, word32* sSz, const byte* buf, word32 len, word32 *idx)
35843587
{
3585-
int result;
3588+
int result = WS_SUCCESS;
35863589
word32 strSz;
35873590
const byte* str;
35883591

3589-
result = GetStringRef(&strSz, &str, buf, len, idx);
3592+
if (s == NULL || sSz == NULL)
3593+
result = WS_BAD_ARGUMENT;
3594+
3595+
if (result == WS_SUCCESS)
3596+
result = GetStringRef(&strSz, &str, buf, len, idx);
3597+
35903598
if (result == WS_SUCCESS) {
35913599
*sSz = (strSz >= *sSz) ? *sSz - 1 : strSz; /* -1 for null char */
3592-
WMEMCPY(s, str, *sSz);
3600+
if (strSz && str)
3601+
WMEMCPY(s, str, *sSz);
35933602
s[*sSz] = 0;
35943603
}
35953604

@@ -3602,22 +3611,24 @@ int GetString(char* s, word32* sSz, const byte* buf, word32 len, word32 *idx)
36023611
int GetStringAlloc(void* heap, char** s, word32* sSz,
36033612
const byte* buf, word32 len, word32 *idx)
36043613
{
3605-
int result;
3614+
int result = WS_SUCCESS;
36063615
const byte *str;
3616+
char* newStr;
36073617
word32 strSz;
36083618

3609-
if (s == NULL) {
3610-
return WS_BAD_ARGUMENT;
3611-
}
3619+
if (s == NULL)
3620+
result = WS_BAD_ARGUMENT;
36123621

3613-
result = GetStringRef(&strSz, &str, buf, len, idx);
3614-
if (result == WS_SUCCESS) {
3615-
char* newStr;
3622+
if (result == WS_SUCCESS)
3623+
result = GetStringRef(&strSz, &str, buf, len, idx);
36163624

3625+
if (result == WS_SUCCESS) {
36173626
newStr = (char*)WMALLOC(strSz + 1, heap, DYNTYPE_STRING);
36183627
if (newStr == NULL)
3619-
return WS_MEMORY_E;
3628+
result = WS_MEMORY_E;
3629+
}
36203630

3631+
if (result == WS_SUCCESS) {
36213632
if (strSz > 0 && str)
36223633
WMEMCPY(newStr, str, strSz);
36233634
newStr[strSz] = 0;
@@ -3638,9 +3649,14 @@ int GetStringAlloc(void* heap, char** s, word32* sSz,
36383649
int GetStringRef(word32* strSz, const byte** str,
36393650
const byte* buf, word32 len, word32* idx)
36403651
{
3641-
int result;
3652+
int result = WS_SUCCESS;
3653+
3654+
if (str == NULL || strSz == NULL)
3655+
result = WS_BAD_ARGUMENT;
3656+
3657+
if (result == WS_SUCCESS)
3658+
result = GetUint32(strSz, buf, len, idx);
36423659

3643-
result = GetUint32(strSz, buf, len, idx);
36443660
if (result == WS_SUCCESS) {
36453661
if (*idx <= len && *strSz <= len - *idx) {
36463662
if (*strSz) {
@@ -6907,8 +6923,8 @@ static int DoUserAuthRequestRsa(WOLFSSH* ssh, WS_UserAuthData_PublicKey* pk,
69076923
}
69086924

69096925
if (ret == WS_SUCCESS) {
6910-
if (publicKeyTypeSz != 7 &&
6911-
WMEMCMP(publicKeyType, "ssh-rsa", 7) != 0) {
6926+
if (publicKeyTypeSz != 7 || publicKeyType == NULL
6927+
|| WMEMCMP(publicKeyType, "ssh-rsa", 7) != 0) {
69126928

69136929
WLOG(WS_LOG_DEBUG,
69146930
"Public Key's type does not match public key type");
@@ -6946,8 +6962,10 @@ static int DoUserAuthRequestRsa(WOLFSSH* ssh, WS_UserAuthData_PublicKey* pk,
69466962
}
69476963

69486964
if (ret == WS_SUCCESS) {
6949-
if (publicKeyTypeSz != pk->publicKeyTypeSz &&
6950-
WMEMCMP(publicKeyType, pk->publicKeyType, publicKeyTypeSz) != 0) {
6965+
if (publicKeyTypeSz != pk->publicKeyTypeSz
6966+
|| publicKeyType == NULL
6967+
|| WMEMCMP(publicKeyType, pk->publicKeyType,
6968+
publicKeyTypeSz) != 0) {
69516969

69526970
WLOG(WS_LOG_DEBUG,
69536971
"Signature's type does not match public key type");

0 commit comments

Comments
 (0)