Skip to content

Commit

Permalink
fixup: request: do consume final linefeed
Browse files Browse the repository at this point in the history
if the line is not empty
Fixes http-request-invalid
  • Loading branch information
catenacyber committed Jan 13, 2025
1 parent 7a789e9 commit 6de3936
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rust/htp/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,7 @@ impl ConnectionParser {
return self.state_request_complete(input);
}
let mut work = input.as_slice();
let mut has_lf = false;
if self.request_status != HtpStreamState::CLOSED {
let request_next_byte = input.as_slice().first();
if request_next_byte.is_none() {
Expand All @@ -1359,6 +1360,7 @@ impl ConnectionParser {

if let Ok((_, line)) = take_till_lf(work) {
work = &line[..line.len() - 1];
has_lf = true;
self.request_data_consume(input, line.len() - 1);
} else {
return self.handle_request_absent_lf(input);
Expand Down Expand Up @@ -1396,6 +1398,11 @@ impl ConnectionParser {
} else {
self.request_body_data_left = Some(1);
}
if has_lf {
//Adds linefeed to the buffer if there was one
self.request_data_consume(input, 1);
data.add(b"\n");
}
// Interpret remaining bytes as body data
let rc = self.request_body_data(Some(&data));
self.request_buf.clear();
Expand Down

0 comments on commit 6de3936

Please sign in to comment.