Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reject HTTP message with duplicate Content-Length header fields #637

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion httpboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ receive_http_response(EFI_HTTP_PROTOCOL *http, VOID **buffer, UINT64 *buf_size)
EFI_HTTP_RESPONSE_DATA response;
EFI_HTTP_STATUS_CODE http_status;
BOOLEAN response_done;
UINTN i, downloaded;
UINTN i, j, downloaded;
CHAR8 rx_buffer[9216];
EFI_STATUS efi_status;
EFI_STATUS event_status;
Expand Down Expand Up @@ -574,6 +574,15 @@ receive_http_response(EFI_HTTP_PROTOCOL *http, VOID **buffer, UINT64 *buf_size)
if (!strcasecmp(rx_message.Headers[i].FieldName,
(CHAR8 *)"Content-Length")) {
*buf_size = ascii_to_int(rx_message.Headers[i].FieldValue);
for(j = 0; j < i; j++) {
if (!strcasecmp(rx_message.Headers[i].FieldName,
(CHAR8 *)"Content-Length")) {
if (*buf_size != ascii_to_int(rx_message.Headers[j].FieldValue)) {
perror(L"Content-Length is invalid\n");
goto error;
}
}
}
}
}

Expand Down
Loading