Fix Coverity scan issues and add false-positive annotations#2131
Draft
workkavint-ship-it wants to merge 8 commits into
Draft
Fix Coverity scan issues and add false-positive annotations#2131workkavint-ship-it wants to merge 8 commits into
workkavint-ship-it wants to merge 8 commits into
Conversation
struct ifreq was declared without an initializer before only the
ifrn_name field was written. The remaining bytes (ifr_ifru union) were
uninitialized when the full struct was passed to setsockopt with
SO_BINDTODEVICE. This is undefined behaviour and a potential information
leak (CWE-457, Coverity CID 56305). Changing the declaration to
struct ifreq interface = {} zero-initializes all fields before use.
readlink() returns ssize_t which can be -1 on failure. Assigning the return value directly to size_t caused the negative value to wrap to SIZE_MAX, resulting in an out-of-bounds write when used as an index into info.filename. Added a return value check before indexing.
Fixed incorrect open() return value checks in ProcessInfo.cpp (Jiffies, ProcessName, Shared, FindChildren, and Resident). The code previously used > 0, which incorrectly treated file descriptor 0 as failure even though it is a valid return value from open(). Updated all checks to != -1 to follow the correct POSIX convention and prevent potential file descriptor leaks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses multiple Coverity findings in Thunder core components by fixing a few safety and edge-case handling issues, along with adding annotations for findings that were reviewed and confirmed to be false positives. The changes mainly focus on improving correctness and avoiding potential runtime issues such as invalid return value handling, out-of-bounds access, resource leaks, and uninitialized variable usage. This PR addresses Coverity issues: #805, #803, #790, #783, #757, #754, #770, #750, #744, #743, #706, and #696.