Skip to content

Fix: accept zero-length header field continuation at receive boundaries - #210

Draft
kstribrnAmzn wants to merge 1 commit into
FreeRTOS:mainfrom
kstribrnAmzn:zeroSplitHeader
Draft

kstribrnAmzn wants to merge 1 commit into
FreeRTOS:mainfrom
kstribrnAmzn:zeroSplitHeader

Conversation

@kstribrnAmzn

Copy link
Copy Markdown
Member

Description

When a transport receive ends exactly at the end of a header field name, llhttp reopens the field span at the start of the next llhttp_execute() buffer and closes it at the ':' separator, invoking on_header_field with a length of zero. This is a valid streaming continuation of the field.
The zero-length guard added to httpParserOnHeaderFieldCallback() in #204 rejected every zero-length callback with LLHTTP_STOP_PARSING, so valid responses failed with HTTPParserInternalError whenever a receive boundary fell right after a header field name (including byte-at-a-time receives).
Only reject a zero-length field when no header field is in progress. Genuinely empty header field names are still rejected by llhttp itself (HTTPSecurityAlertInvalidCharacter) before any span callback fires.

Test Steps

Add a unit test that splits the response at the end of a header field name and expects the response to parse successfully.

Checklist:

  • I have tested my changes. No regression in existing tests.
  • I have modified and/or added unit-tests to cover the code changes in this Pull Request.

Related Issue

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

When a transport receive ends exactly at the end of a header field name,
llhttp reopens the field span at the start of the next llhttp_execute()
buffer and closes it at the ':' separator, invoking on_header_field with
a length of zero. This is a valid streaming continuation of the field.

The zero-length guard added to httpParserOnHeaderFieldCallback() in FreeRTOS#204
rejected every zero-length callback with LLHTTP_STOP_PARSING, so valid
responses failed with HTTPParserInternalError whenever a receive boundary
fell right after a header field name (including byte-at-a-time receives).

Only reject a zero-length field when no header field is in progress.
Genuinely empty header field names are still rejected by llhttp itself
(HTTPSecurityAlertInvalidCharacter) before any span callback fires.

Add a unit test that splits the response at the end of a header field
name and expects the response to parse successfully.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant