Repository navigation
fix(helpers): prevent slice out-of-bounds in PkgToPurl with odd-length qualifiers - #3293
vishnums2k5 wants to merge 1 commit into
Conversation
…h qualifiers PkgToPurl iterated over qualifiersList with a range loop and a modulo-2 check, then unconditionally accessed qualifiersList[i+1]. When the caller passed a qualifiers slice of odd length (an unpaired trailing key), the access panicked with an index-out-of-range error. Replace the range loop with an explicit step-2 loop that checks i+1 < len(qualifiersList) before reading the value. Unpaired keys are silently dropped, matching the existing contract that qualifiers are supplied as key-value pairs. Three new table-driven test cases added to TestPkgToPurl: - odd-length list with one valid pair and a trailing orphan key - single unpaired key (length 1) - empty qualifiers list (no change in behaviour, verified explicitly) Signed-off-by: vishnums2k5 <vishnusajeev2005@gmail.com>
mihaimaruseac
left a comment
There was a problem hiding this comment.
This doesn't look like a scenario that happens in practice
Thank you for the review. You're right — tracing the actual call paths, I'll look for issues that are demonstrably reachable before opening |
|
Please don't just be a meat-proxy (or just sic your agent on the repo). Please review the contribution before opening the PR. |
|
Understood and point taken, Mihai. I sincerely apologize for wasting your review time with speculative edge cases. I'm stepping back to properly run the full system and will only focus on confirmed, reproducible issues in the future. |
Description of the PR
PkgToPurliterated overqualifiersListwith a range loop and amodulo-2 check, then unconditionally accessed
qualifiersList[i+1].When the caller passes a qualifiers slice of odd length (an unpaired
trailing key), the access panics with an index-out-of-range error.
This PR replaces the range loop with an explicit step-2 loop that
checks
i+1 < len(qualifiersList)before reading the value. Unpairedtrailing keys are silently dropped, matching the existing contract that
qualifiers are supplied as key-value pairs.
Three new table-driven test cases cover: an odd-length list with one
valid pair and a trailing orphan key, a single unpaired key (length 1),
and an empty qualifiers list.
PR Checklist
-sflag togit commit.make generatehas been runmake generatehas been runmake generatehas been runcollectsubprotobuf has been changed,make protohas been run