-
Notifications
You must be signed in to change notification settings - Fork 79
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 static code analysis warnings #428
Fix static code analysis warnings #428
Conversation
Prevent possibility of use after free.
base/networking.c
Outdated
@@ -782,9 +782,9 @@ ip_islocalhost (struct sockaddr_storage *storage) | |||
struct in_addr addr; | |||
struct in_addr *addr_p; | |||
struct in6_addr addr6; | |||
struct in6_addr *addr6_p; | |||
struct in6_addr *addr6_p = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These look wrong, because they're set directly below. Wouldn't recommend adding them just to quiet clang, but if you want to I recommend adding a note that it's for clang.
base/logging.c
Outdated
@@ -510,7 +510,7 @@ gvm_log_func (const char *log_domain, GLogLevelFlags log_level, | |||
/* Make the tmp pointer (for iteration) point to the format string. */ | |||
tmp = prepend_format; | |||
|
|||
while (*tmp != '\0') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess there should rather be a NULL check at line 483 like there is at line 441, to prevent prepend_format from ever being NULL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's good to let tmp be NULL because then prepend_buf ends up "" instead of the default "%t %s %p - ".
Remove possibility of having garbage value in call to IN6_ARE_ADDR_EQUAL
gnutls_certificate_set_dh_params only stores a pointer to the parameters in the certificate handle, so you must not deallocate the parameters before the certificate is deallocated.
77d8697
to
1533c00
Compare
What:
Fix warnings of static code analysis.
Why:
Improve code quality and make CI happy.
How:
Install
clang-tools-7
and run static code analysis with e.g.:mkdir build && cd build/ && /bin/scan-build-7 cmake -DCMAKE_BUILD_TYPE=Debug .. && /bin/scan-build-7 -o tmp/scan-build-report make && [ -z "$(ls -A tmp/scan-build-report/)" ]
Checklist: