Skip to content

Commit a38e37a

Browse files
committed
Fix some minor sanitizer issues with use of NULL.
1 parent fa786be commit a38e37a

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

src/internal.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6794,7 +6794,8 @@ int WP11_Session_SetAesWrapParams(WP11_Session* session, byte* iv, word32 ivLen,
67946794
WP11_Lock_UnlockRO(object->lock);
67956795
}
67966796
if (ret == 0) {
6797-
XMEMCPY(wrap->iv, iv, ivLen);
6797+
if (iv != NULL)
6798+
XMEMCPY(wrap->iv, iv, ivLen);
67986799
wrap->ivSz = ivLen;
67996800
}
68006801

@@ -8123,7 +8124,8 @@ static int GetData(byte* data, CK_ULONG dataLen, byte* out, CK_ULONG* outLen)
81238124
ret = BUFFER_E;
81248125
else {
81258126
*outLen = dataLen;
8126-
XMEMCPY(out, data, dataLen);
8127+
if (data != NULL)
8128+
XMEMCPY(out, data, dataLen);
81278129
}
81288130

81298131
return ret;
@@ -8912,10 +8914,10 @@ static int WP11_Object_SetKeyId(WP11_Object* object, unsigned char* keyId,
89128914
DYNAMIC_TYPE_TMP_BUFFER);
89138915
if (object->keyId == NULL)
89148916
ret = MEMORY_E;
8915-
}
8916-
if (ret == 0) {
8917-
XMEMCPY(object->keyId, keyId, keyIdLen);
8918-
object->keyIdLen = keyIdLen;
8917+
if (ret == 0) {
8918+
XMEMCPY(object->keyId, keyId, keyIdLen);
8919+
object->keyIdLen = keyIdLen;
8920+
}
89198921
}
89208922

89218923
return ret;
@@ -8943,10 +8945,10 @@ static int WP11_Object_SetData(byte** attribute, int* attributeLen, byte* data,
89438945
DYNAMIC_TYPE_TMP_BUFFER);
89448946
if (*attribute == NULL)
89458947
ret = MEMORY_E;
8946-
}
8947-
if (ret == 0) {
8948-
XMEMCPY(*attribute, data, dataLen);
8949-
*attributeLen = dataLen;
8948+
if (ret == 0) {
8949+
XMEMCPY(*attribute, data, dataLen);
8950+
*attributeLen = dataLen;
8951+
}
89508952
}
89518953

89528954
return ret;

0 commit comments

Comments
 (0)