Skip to content

Fix Coverity scan issues and add false-positive annotations#2131

Draft
workkavint-ship-it wants to merge 8 commits into
masterfrom
development/coverity-scan-fixes-1
Draft

Fix Coverity scan issues and add false-positive annotations#2131
workkavint-ship-it wants to merge 8 commits into
masterfrom
development/coverity-scan-fixes-1

Conversation

@workkavint-ship-it
Copy link
Copy Markdown

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.

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.
Comment thread Source/core/ProcessInfo.cpp Fixed
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