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

Clam 2296 coverity regressions #891

Merged
merged 11 commits into from Apr 13, 2023
Merged

Conversation

micahsnyder
Copy link
Contributor

Fix a number of recent coverity issues introduced during 1.1 dev, along with a large number of compile time warnings:

  • Fix many warnings

  • Fix benign compiler warning in logging macro

  • The strncpy intentionally is not copying the NULL terminator for the log message prefix. The NULL will be added by vsnprintf, after. Switching to memcpy eliminates the warning.

  • Fix possibly uninitialized variable warning

  • Coverity-401433: Fix file descriptor leak in VBA parser

  • Coverity-401434: Switch to realloc that does not free after failure

  • Because we free after the done-label.

  • Coverity-404677: Add missing frees in sigtool

  • Coverity-405726, 405725: Fix overlapping copy complaint

  • Fix issue introduced during 1.1 dev.

  • Fix coverity-405726 coverity-405725.

  • Coverity-405733, 405732: Add missing variable initializers

  • Coverity-405734: Add missing variable initializer

  • Coverity-405735: Add missing 'goto done;' on error

Copy link
Contributor

@ragusaa ragusaa left a comment

Choose a reason for hiding this comment

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

Code looks good, just made a few suggestions.

clamav-milter/clamav-milter.c Show resolved Hide resolved
@@ -417,6 +419,7 @@ int cli_versig2(const unsigned char *sha256, const char *dsig_str, const char *n
return memcmp(digest1, digest2, HASH_LEN) ? CL_EVERIFY : CL_SUCCESS;

done:
free(decoded);
Copy link
Contributor

Choose a reason for hiding this comment

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

It is specified in the man page to not do anything if 'decoded' is NULL. Are there any platforms that do not honor this? Should we add a test just to be safe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used to be superstitious about this, but from what I can tell it's safe everywhere if the pointer is NULL.
E.g. on Windows: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/free?view=msvc-170

libclamav/explode.c Show resolved Hide resolved
libclamav/scanners.c Show resolved Hide resolved
Coverity complained about missing break statements for two switch cases
that end with asserts.

Adding /* fall-through */ comments appears to assuage Coverity's fears.
@micahsnyder micahsnyder force-pushed the CLAM-2296-coverity-regressions branch from abbd351 to c8fcabe Compare April 12, 2023 17:12
@micahsnyder micahsnyder merged commit 5b27982 into main Apr 13, 2023
19 of 24 checks passed
@micahsnyder micahsnyder deleted the CLAM-2296-coverity-regressions branch May 1, 2023 19:36
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

2 participants