Commit ba889908 authored by Kenton Varda's avatar Kenton Varda Committed by GitHub

Merge pull request #569 from ecatmur/http-header-null-reference

Don't bind Header reference to a null pointer.
parents eadeea59 d909c711
...@@ -1953,8 +1953,7 @@ public: ...@@ -1953,8 +1953,7 @@ public:
} }
kj::Promise<Message> receive() override { kj::Promise<Message> receive() override {
auto& recvHeader = *reinterpret_cast<Header*>(recvData.begin()); size_t headerSize = Header::headerSize(recvData.begin(), recvData.size());
size_t headerSize = recvHeader.headerSize(recvData.size());
if (headerSize > recvData.size()) { if (headerSize > recvData.size()) {
if (recvData.begin() != recvBuffer.begin()) { if (recvData.begin() != recvBuffer.begin()) {
...@@ -1982,6 +1981,8 @@ public: ...@@ -1982,6 +1981,8 @@ public:
}); });
} }
auto& recvHeader = *reinterpret_cast<Header*>(recvData.begin());
recvData = recvData.slice(headerSize, recvData.size()); recvData = recvData.slice(headerSize, recvData.size());
size_t payloadLen = recvHeader.getPayloadLen(); size_t payloadLen = recvHeader.getPayloadLen();
...@@ -2231,7 +2232,7 @@ private: ...@@ -2231,7 +2232,7 @@ private:
} }
} }
size_t headerSize(size_t sizeSoFar) { static size_t headerSize(byte const* bytes, size_t sizeSoFar) {
if (sizeSoFar < 2) return 2; if (sizeSoFar < 2) return 2;
size_t required = 2; size_t required = 2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment