Fix raw HTTP parser panic on single-LF request body - #7525
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe request-body trailing newline trimming logic in ParseRawRequest was updated to check that the byte slice is non-empty before indexing its last byte, preventing an index-out-of-range panic. A new test verifies parsing behavior for bodies with empty, LF-only, and CRLF-only trailing content. ChangesRaw request body trim panic fix
Estimated code review effort: 1 (Trivial) | ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The functional test failures appear unrelated to this PR. The jobs fail while
This happens before the functional tests execute, across macOS, Ubuntu, and Windows. Please let me know if you would like me to re-run the checks once the action/download issue is resolved. |
Summary
Fixes a panic in the raw HTTP request parser when the request body is empty or contains only newline characters.
ParseRawRequesttrimmed a trailing newline and then immediately accessed the final byte again. For a body containing only"\n", the first trim left an empty slice and the next access could panic with:Changes
Add length guards around raw request body trailing-newline trimming.
Preserve the existing parsing behavior for normal bodies.
Add regression coverage for:
"\n""\r\n""""A\n"Cover both
ParseRawRequestandParseRawRequestWithURL.Tests
Closes #7524.
Summary by CodeRabbit