Fix Codacy findings: bounded read helpers, remove cppcheck suppressions, and harden mk_kelf.sh#79
Merged
Conversation
Codacy's Analysis Summary0 new issue (≤ 0 issue) Review Pull Request in Codacy →
|
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.
Motivation
rm -rfexpansion in archive creation by ensuringDATE,SHA8, andTARGETare set and non-empty.Description
src/util_safeio.csosafe_read_loopusessize_t-basedmax_payload, caps eachread()by remaining capacity, returns on read errors, stops on EOF, and always NUL-terminates when requested.cppchecksuppression comments fromsrc/OSDHistory.cand switched the code to call the bounded helpersafe_read_fully_bin.scripts/cppcheck.shand updatedREADME.mdguidance to direct Codacy to shim headers rather than using suppression lists.mk_kelf.shby adding precondition checks forDATE,SHA8, andTARGET, checking for unsafeTARGETvalues, and usingrm -rf -- "${TARGET:?}/"to avoid empty/root expansion.Testing
rg -n "cppcheck-suppress"and confirmed no occurrences remain; this check passed (no results).scripts/cppcheck.shno longer passes a suppression list by inspecting the script content (scripts/cppcheck.shlines 20–28) and updatedREADME.mdguidance accordingly; this check passed.src/util_safeio.cto confirm the read loop caps payload withsize_tand NUL-terminates when requested (src/util_safeio.cread loop region); this check passed.mk_kelf.shcontains: "${DATE:?DATE is unset or empty}",: "${SHA8:?SHA8 is unset or empty}", and usesrm -rf -- "${TARGET:?}/"to prevent unsafe expansion (mk_kelf.shguards andrm -rflines); this check passed.Codex Task