mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2024-12-25 01:29:53 +03:00
src/Mayaqua/Secure.c: fix potential null pointer dereference
found by coverity CID 343528 (#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. 438 if (name == NULL || k == NULL || k->private_key == false) 439 { 440 sec->Error = SEC_ERROR_BAD_PARAMETER; 441 return false; 442 }
This commit is contained in:
parent
db7d6c83d5
commit
c59df82666
@ -404,6 +404,28 @@ bool WriteSecKey(SECURE *sec, bool private_obj, char *name, K *k)
|
||||
UCHAR modules[MAX_SIZE], pub[MAX_SIZE], pri[MAX_SIZE], prime1[MAX_SIZE], prime2[MAX_SIZE];
|
||||
UCHAR exp1[MAX_SIZE], exp2[MAX_SIZE], coeff[MAX_SIZE];
|
||||
const BIGNUM *n, *e, *d, *p, *q, *dmp1, *dmq1, *iqmp;
|
||||
|
||||
// Validate arguments
|
||||
if (sec == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (name == NULL || k == NULL || k->private_key == false)
|
||||
{
|
||||
sec->Error = SEC_ERROR_BAD_PARAMETER;
|
||||
return false;
|
||||
}
|
||||
if (sec->SessionCreated == false)
|
||||
{
|
||||
sec->Error = SEC_ERROR_NO_SESSION;
|
||||
return false;
|
||||
}
|
||||
if (sec->LoginFlag == false && private_obj)
|
||||
{
|
||||
sec->Error = SEC_ERROR_NOT_LOGIN;
|
||||
return false;
|
||||
}
|
||||
|
||||
CK_ATTRIBUTE a[] =
|
||||
{
|
||||
{CKA_MODULUS, modules, 0}, // 0
|
||||
@ -430,27 +452,6 @@ bool WriteSecKey(SECURE *sec, bool private_obj, char *name, K *k)
|
||||
{CKA_MODIFIABLE, &b_false, sizeof(b_false)},
|
||||
};
|
||||
|
||||
// Validate arguments
|
||||
if (sec == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (name == NULL || k == NULL || k->private_key == false)
|
||||
{
|
||||
sec->Error = SEC_ERROR_BAD_PARAMETER;
|
||||
return false;
|
||||
}
|
||||
if (sec->SessionCreated == false)
|
||||
{
|
||||
sec->Error = SEC_ERROR_NO_SESSION;
|
||||
return false;
|
||||
}
|
||||
if (sec->LoginFlag == false && private_obj)
|
||||
{
|
||||
sec->Error = SEC_ERROR_NOT_LOGIN;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Numeric data generation
|
||||
rsa = EVP_PKEY_get0_RSA(k->pkey);
|
||||
if (rsa == NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user