Skip to content

Commit

Permalink
Fix fuzzing tests for HTTPBinaryCodec for incompletely formed messages
Browse files Browse the repository at this point in the history
Summary: Task T135622359 showed a fuzzing test failure where the HTTPBinaryCodec could crash on incompletely formed messages. This diff patches the issue.

Reviewed By: zhang00000

Differential Revision: D40861967

fbshipit-source-id: 3443686b37b972bff1a8839335b4df055f4552ba
  • Loading branch information
Shiv Kushwah authored and facebook-github-bot committed Nov 1, 2022
1 parent 235cd7a commit 908da97
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,20 @@ void HTTPBinaryCodec::onIngressEOF() {
HTTPException(HTTPException::Direction::INGRESS,
fmt::format("Invalid Message: {}", *parseError_)));
} else {
// Case where the sent message only contains control data
if (!msg_ && state_ == ParseState::HEADERS_SECTION) {
msg_ = std::move(decodeInfo_.msg);

if (!msg_) {
if (state_ == ParseState::HEADERS_SECTION) {
// Case where the sent message only contains control data
msg_ = std::move(decodeInfo_.msg);
} else {
callback_->onError(
ingressTxnID_,
HTTPException(
HTTPException::Direction::INGRESS,
fmt::format("Message not formed (incomplete binary data)")));
return;
}
}
CHECK(msg_);
callback_->onHeadersComplete(ingressTxnID_, std::move(msg_));
if (msgBody_) {
callback_->onBody(ingressTxnID_, std::move(msgBody_), 0);
Expand Down

0 comments on commit 908da97

Please sign in to comment.