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

Fix incorrect expressions reported by Coverity #2035

Merged

Conversation

0intro
Copy link
Contributor

@0intro 0intro commented Sep 20, 2023

This change fixes incorrect expressions reported by Coverity.

@0intro 0intro force-pushed the coverity-incorrect-expressions-20230920 branch from 09a532b to 4a6c82f Compare September 20, 2023 12:06
@jan-cerny jan-cerny self-assigned this Sep 25, 2023
@jan-cerny jan-cerny added this to the 1.3.10 milestone Sep 25, 2023
Copy link
Member

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

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

The CI fail is a problem is sysctl probe which become incompatible with the kernel, the CI fail isn't related to the contents of this PR.

@@ -74,7 +74,7 @@ int64_t strto_int64 (const char *str, size_t len, char **endptr, int base)
{
int errno_copy = 0;
int64_t result = 0;
char *null_str = calloc(len + 1, sizeof(str));
char *null_str = calloc(len + 1, sizeof(*str));
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be easier and more redable to just use malloc() here than using sizeof on a const char.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could use malloc, but I think, in this case, we should also call memset so the string would be null terminated.

Copy link
Member

Choose a reason for hiding this comment

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

makes sense

@jan-cerny jan-cerny merged commit 3a987f3 into OpenSCAP:maint-1.3 Sep 26, 2023
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.

2 participants