fix(pvs): resolve Medium Level (Level 2) static analyzer warnings - #87
Open
bivex wants to merge 3 commits into
Open
fix(pvs): resolve Medium Level (Level 2) static analyzer warnings#87bivex wants to merge 3 commits into
bivex wants to merge 3 commits into
Conversation
- Fix potential buffer overflow and bounds check in main.c (preprocess) - Fix termios c_lflag bitmask truncation on 64-bit platforms in mesg.c - Fix potential null pointer dereferences in pangen2.c, pangen3.c, and run.c - Fix undefined behavior in 64-bit bit shift operations (1UL<<j) in pangen6.c - Fix EVAL AST node child type check logic in pangen6.c - Fix code formatting ambiguity in pangen7.c - Fix potential division by zero modulo in run.c
- Add array bounds guards for string operations in guided.c, msc_tcl.c, and structs.c - Fix sizeof(IArg_cont[IArgno]) target buffer in spinlex.c - Fix block scope formatting in spinlex.c - Declare alldone(int) with noreturn attribute and fix comparison logic in main.c - Guard NULL pointers in eligible() in pangen5.c - Clean up redundant pointer checks in flow.c and mesg.c - Remove redundant loop condition in pangen1.c - Add fallthrough annotations, simplify boolean logic, and remove dead assignment in pangen2.c - Remove unreachable code after fatal() in sym.c - Parenthesize assignment and ternary operator expression in tl_mem.c
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 resolves Medium Level (Level 2) static analyzer warnings reported by PVS-Studio across the Spin codebase.
Key Improvements
Src/guided.c&Src/msc_tcl.c: Added length guards before string index mutations (strlen(snap) >= 2).Src/structs.c: Expandedeprefixbuffer size to 512 and added string length guards.Src/spinlex.c: Correctedsizeof(IArg_cont)tosizeof(IArg_cont[IArgno])to inspect individual 1D row array sizes instead of full 2D array size.Src/main.c: Markedalldone(int)withnoreturnattribute.Src/pangen5.c: Safely guardedvandv->steppointers ineligible().Src/flow.c&Src/mesg.c: Removed redundant pointer checks inside loops where pointers are guaranteed non-null.Src/pangen1.c: Removed redundant loop termination check.Src/pangen2.c: Added explicit/* FALLTHROUGH */annotations, simplified boolean expressions, and removed dead assignments.Src/sym.c: Removed dead code following non-returningfatal()calls.Src/tl_mem.c: Explicitly parenthesized compound assignment expressions.Verification
make clean && make) with zero errors.