Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

27 klockwork cleanup #45

Merged
merged 2 commits into from
Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions src/src_main/crypto_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,20 @@ int32_t Crypto_Config_MariaDB(char *mysql_username, char *mysql_password, char *
{
int32_t status = CRYPTO_LIB_SUCCESS;
sadb_mariadb_config = (SadbMariaDBConfig_t *)calloc(1, SADB_MARIADB_CONFIG_SIZE);
sadb_mariadb_config->mysql_username = mysql_username;
sadb_mariadb_config->mysql_password = mysql_password;
sadb_mariadb_config->mysql_hostname = mysql_hostname;
sadb_mariadb_config->mysql_database = mysql_database;
sadb_mariadb_config->mysql_port = mysql_port;
if(sadb_mariadb_config != NULL)
{
sadb_mariadb_config->mysql_username = mysql_username;
sadb_mariadb_config->mysql_password = mysql_password;
sadb_mariadb_config->mysql_hostname = mysql_hostname;
sadb_mariadb_config->mysql_database = mysql_database;
sadb_mariadb_config->mysql_port = mysql_port;
}
else
{
// null returned, throw error and return
status = CRYPTO_LIB_ERR_NULL_BUFFER;
}

return status;
}

Expand All @@ -236,13 +245,22 @@ int32_t Crypto_Config_Add_Gvcid_Managed_Parameter(uint8_t tfvn, uint16_t scid, u
if (gvcid_managed_parameters == NULL)
{ // case: Global Root Node not Set
gvcid_managed_parameters = (GvcidManagedParameters_t *)calloc(1, GVCID_MANAGED_PARAMETERS_SIZE);
gvcid_managed_parameters->tfvn = tfvn;
gvcid_managed_parameters->scid = scid;
gvcid_managed_parameters->vcid = vcid;
gvcid_managed_parameters->has_fecf = has_fecf;
gvcid_managed_parameters->has_segmentation_hdr = has_segmentation_hdr;
gvcid_managed_parameters->next = NULL;
return status;
if(gvcid_managed_parameters != NULL)
{
gvcid_managed_parameters->tfvn = tfvn;
gvcid_managed_parameters->scid = scid;
gvcid_managed_parameters->vcid = vcid;
gvcid_managed_parameters->has_fecf = has_fecf;
gvcid_managed_parameters->has_segmentation_hdr = has_segmentation_hdr;
gvcid_managed_parameters->next = NULL;
return status;
}
else
{
// calloc failed - return error
status = CRYPTO_LIB_ERR_NULL_BUFFER;
return status;
}
}
else
{ // Recurse through nodes and add at end
Expand Down
1 change: 1 addition & 0 deletions src/src_main/crypto_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ int32_t Crypto_TC_ApplySecurity(const uint8_t *p_in_frame, const uint16_t in_fra
{
printf(KRED "ERROR: CryptoLib Configuration Not Set! -- CRYPTO_LIB_ERR_NO_CONFIG, Will Exit\n" RESET);
status = CRYPTO_LIB_ERR_NO_CONFIG;
return status; // return immediately so a NULL crypto_config is not dereferenced later
}

// Primary Header
Expand Down
1 change: 1 addition & 0 deletions support/ansible/cryptolib-centos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
- python3-devel
- python3-pip
- kernel-devel
- mysql-devel
# add additional packages here

- name: Install pycryptodome
Expand Down
7 changes: 5 additions & 2 deletions util/src_util/apply_security.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

int main(int argc, char *argv[])
{
char *buffer;
char *buffer = NULL;
const char *filename;
long buffer_size;
char st[64];
Expand All @@ -48,6 +48,9 @@ int main(int argc, char *argv[])
return CRYPTO_LIB_ERROR;
}
buffer = c_read_file(filename, &buffer_size);
if(buffer == NULL)
return -1;

debug_printf("File buffer size:%lu\n", buffer_size);
uint32_t buffer_size_i = (uint32_t)buffer_size;
debug_printf("File buffer size int:%d\n", buffer_size_i);
Expand All @@ -58,7 +61,7 @@ int main(int argc, char *argv[])
Crypto_Init();

uint8_t *ptr_enc_frame = NULL;
uint16_t enc_frame_len;
uint16_t enc_frame_len = 0;

// Call ApplySecurity on buffer contents depending on type.
if (strcmp(security_type, "tc") == 0)
Expand Down