1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-22 09:29:52 +03:00

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

found by coverity

   CID 343537 (#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.
   664        if (name == NULL)
   665        {
   666                sec->Error = SEC_ERROR_BAD_PARAMETER;
   667                return false;
   668        }
This commit is contained in:
Ilya Shipitsin 2023-05-01 06:09:38 +02:00
parent a89adaebc3
commit db7d6c83d5

View File

@ -640,22 +640,6 @@ bool WriteSecCert(SECURE *sec, bool private_obj, char *name, X *x)
UINT ret;
BUF *b;
UINT object;
CK_ATTRIBUTE a[] =
{
{CKA_SUBJECT, subject, 0}, // 0
{CKA_ISSUER, issuer, 0}, // 1
{CKA_SERIAL_NUMBER, serial_number, 0}, // 2
{CKA_VALUE, value, 0}, // 3
{CKA_CLASS, &obj_class, sizeof(obj_class)},
{CKA_TOKEN, &b_true, sizeof(b_true)},
{CKA_PRIVATE, &b_private_obj, sizeof(b_private_obj)},
{CKA_LABEL, name, StrLen(name)},
{CKA_CERTIFICATE_TYPE, &cert_type, sizeof(cert_type)},
#if 0 // Don't use these because some tokens fail
{CKA_START_DATE, &start_date, sizeof(start_date)},
{CKA_END_DATE, &end_date, sizeof(end_date)},
#endif
};
// Validate arguments
if (sec == NULL)
{
@ -677,6 +661,23 @@ bool WriteSecCert(SECURE *sec, bool private_obj, char *name, X *x)
return false;
}
CK_ATTRIBUTE a[] =
{
{CKA_SUBJECT, subject, 0}, // 0
{CKA_ISSUER, issuer, 0}, // 1
{CKA_SERIAL_NUMBER, serial_number, 0}, // 2
{CKA_VALUE, value, 0}, // 3
{CKA_CLASS, &obj_class, sizeof(obj_class)},
{CKA_TOKEN, &b_true, sizeof(b_true)},
{CKA_PRIVATE, &b_private_obj, sizeof(b_private_obj)},
{CKA_LABEL, name, StrLen(name)},
{CKA_CERTIFICATE_TYPE, &cert_type, sizeof(cert_type)},
#if 0 // Don't use these because some tokens fail
{CKA_START_DATE, &start_date, sizeof(start_date)},
{CKA_END_DATE, &end_date, sizeof(end_date)},
#endif
};
// Copy the certificate to the buffer
b = XToBuf(x, false);
if (b == NULL)