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

Free memory in Parodus during exit/shutdown #425

Merged
merged 2 commits into from
Jul 20, 2023

Conversation

shilpa24balaji
Copy link
Collaborator

@shilpa24balaji shilpa24balaji commented Jul 12, 2023

To free memory of few config in Parodus during the shutdown case

Signed-off-by: Mohamed Shaikh <mohamed.shaikh@t-systems.com>
@guardrails
Copy link

guardrails bot commented Jul 12, 2023

⚠️ We detected 8 security issues in this pull request:

Insecure Processing of Data (8)
Severity Details Docs
High Title: Use after free
free(cfg->mtls_client_cert_path);
📚
High Title: Use after free
free(cfg->connection_health_file);
📚
High Title: Use after free
free(cfg->token_server_url );
📚
High Title: Use after free
free(cfg->mtls_client_key_path);
📚
High Title: Use after free
free(cfg->client_cert_path);
📚
High Title: Use after free
free(cfg->crud_config_file);
📚
High Title: Use after free
free(cfg->close_reason_file);
📚
High Title: Use after free
free(cfg->cloud_disconnect);
📚

More info on how to fix Insecure Processing of Data in C/C++.


👉 Go to the dashboard for detailed results.

📥 Happy? Share your feedback with us.

@shilpa24balaji
Copy link
Collaborator Author

shilpa24balaji commented Jul 12, 2023

@sadhyama Not able to resolve the security warning even after pointers are set to null
CC: @akif1716

@sadhyama sadhyama closed this Jul 13, 2023
@sadhyama sadhyama reopened this Jul 13, 2023
src/config.c Outdated
@@ -711,6 +711,50 @@ int parseCommandLine(int argc,char **argv,ParodusCfg * cfg)
return 0;
}

void free_cfg(ParodusCfg *cfg)
{
if (cfg->mtls_client_cert_path != NULL )
Copy link
Contributor

@sadhyama sadhyama Jul 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add cfg NULL check and see if it is helping to fix warning, and assign cfg to NULL at the end once elements are freed .

cfg can be NULL as per this

ParodusError("cfg is NULL\n");
at setDefaultValuesToCfg()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cfg I traced back is pointer to static global struct variable so ideally we should not assign it NULL
https://github.com/xmidt-org/parodus/blob/master/src/config.c#L44

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added NULL check but not able to run guardrails again to confirm

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sadhyama Any update on this?

@schmidtw
Copy link
Member

This code looks correct to me. I'm merging it.

@schmidtw schmidtw merged commit 85a0d9b into xmidt-org:master Jul 20, 2023
2 of 5 checks passed
@@ -231,6 +231,9 @@ void createSocketConnection(void (* initKeypress)())
nopoll_ctx_unref(ctx);
nopoll_cleanup_library();
curl_global_cleanup();
clear_metadata();
rdk_logger_deinit();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Facing build error due to this in local Ubuntu pc,

/usr/bin/ld: CMakeFiles/parodus.dir/conn_interface.c.o: in function createSocketConnection': conn_interface.c:(.text+0x89b): undefined reference to rdk_logger_deinit'
collect2: error: ld returned 1 exit status
make[2]: *** [src/CMakeFiles/parodus.dir/build.make:519: src/parodus] Error 1
make[1]: *** [CMakeFiles/Makefile2:1274: src/CMakeFiles/parodus.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shilpa24balaji Could you please help to check this ?
rdk_logger_deinit func is not available in local pc code hence this error.
For now we are proceeding by disabling this func call from conn_interface.c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants