1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-06 01:30:40 +03:00

src/Mayaqua/Secure.c: fix potential null pointer dereference

found by coverity

 CID 343536 (#1 of 1): Dereference before null check (REVERSE_INULL)
 check_after_deref: Null-checking name suggests that it may be null, but
 it has already been dereferenced on all paths leading to the check.
 1339        if (name == NULL || data == NULL || size == 0)
 1340        {
 1341                sec->Error = SEC_ERROR_BAD_PARAMETER;
 1342                return false;
 1343        }
This commit is contained in:
Ilya Shipitsin 2023-05-01 06:07:19 +02:00
parent aadc068964
commit a89adaebc3

View File

@ -1313,14 +1313,6 @@ bool WriteSecData(SECURE *sec, bool private_obj, char *name, void *data, UINT si
UINT object_class = CKO_DATA; UINT object_class = CKO_DATA;
CK_BBOOL b_true = true, b_false = false, b_private_obj = private_obj; CK_BBOOL b_true = true, b_false = false, b_private_obj = private_obj;
UINT object; UINT object;
CK_ATTRIBUTE a[] =
{
{CKA_TOKEN, &b_true, sizeof(b_true)},
{CKA_CLASS, &object_class, sizeof(object_class)},
{CKA_PRIVATE, &b_private_obj, sizeof(b_private_obj)},
{CKA_LABEL, name, StrLen(name)},
{CKA_VALUE, data, size},
};
// Validate arguments // Validate arguments
if (sec == NULL) if (sec == NULL)
{ {
@ -1347,6 +1339,15 @@ bool WriteSecData(SECURE *sec, bool private_obj, char *name, void *data, UINT si
return false; return false;
} }
CK_ATTRIBUTE a[] =
{
{CKA_TOKEN, &b_true, sizeof(b_true)},
{CKA_CLASS, &object_class, sizeof(object_class)},
{CKA_PRIVATE, &b_private_obj, sizeof(b_private_obj)},
{CKA_LABEL, name, StrLen(name)},
{CKA_VALUE, data, size},
};
// Delete any objects with the same name // Delete any objects with the same name
if (CheckSecObject(sec, name, SEC_DATA)) if (CheckSecObject(sec, name, SEC_DATA))
{ {