fix: add integer overflow check in filesystem.c...#75
Conversation
Automated security fix generated by OrbisAI Security
There was a problem hiding this comment.
Pull request overview
This PR updates src/filesystem.c to address a reported integer-overflow-in-allocation finding and to simplify a few string copy operations.
Changes:
- Replace
strncpy+ impossible NULL-return checks with directmemcpyin path helper functions. - Switch filename buffer allocation from
malloc(sizeof(char) * (MAX_STR_SIZE + 1))tocalloc(MAX_STR_SIZE + 1, sizeof(char)). - Replace
strncpywithmemcpywhen copyingdirent->d_nameinto the allocated buffer.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
✅ Review Feedback Addressed I've automatically addressed 2 review comment(s): Two functions in
Files modified:
The changes have been pushed to this PR branch. Please review! |
Summary
Fix high severity security issue in
src/filesystem.c.Vulnerability
utils.custom.integer-overflow-mallocsrc/filesystem.c:489Description: Arithmetic multiplication used to compute allocation size without overflow check. If the multiplication wraps, a too-small buffer is allocated, leading to heap overflow. Check for overflow before allocating.
Changes
src/filesystem.cVerification
Automated security fix by OrbisAI Security