Add some checks.

GitOrigin-RevId: 6c24e7d3d48ed823a45d6b106855f3a0f55a0db5
This commit is contained in:
levlam 2020-05-19 15:11:21 +03:00
parent 4c80155092
commit 088a96ff15
3 changed files with 4 additions and 1 deletions

View File

@ -148,6 +148,7 @@ Result<size_t> HttpReader::read_next(HttpQuery *query) {
end_p--; end_p--;
} }
CHECK(p != nullptr);
Slice boundary(p, static_cast<size_t>(end_p - p)); Slice boundary(p, static_cast<size_t>(end_p - p));
if (boundary.empty() || boundary.size() > MAX_BOUNDARY_LENGTH) { if (boundary.empty() || boundary.size() > MAX_BOUNDARY_LENGTH) {
return Status::Error(400, "Bad Request: boundary too big or empty"); return Status::Error(400, "Bad Request: boundary too big or empty");

View File

@ -515,6 +515,7 @@ int strm_read(BIO *b, char *buf, int len) {
auto *stream = static_cast<SslStreamImpl *>(BIO_get_data(b)); auto *stream = static_cast<SslStreamImpl *>(BIO_get_data(b));
CHECK(stream != nullptr); CHECK(stream != nullptr);
BIO_clear_retry_flags(b); BIO_clear_retry_flags(b);
CHECK(buf != nullptr);
int res = narrow_cast<int>(stream->flow_read(MutableSlice(buf, len))); int res = narrow_cast<int>(stream->flow_read(MutableSlice(buf, len)));
if (res == 0) { if (res == 0) {
BIO_set_retry_read(b); BIO_set_retry_read(b);
@ -526,6 +527,7 @@ int strm_write(BIO *b, const char *buf, int len) {
auto *stream = static_cast<SslStreamImpl *>(BIO_get_data(b)); auto *stream = static_cast<SslStreamImpl *>(BIO_get_data(b));
CHECK(stream != nullptr); CHECK(stream != nullptr);
BIO_clear_retry_flags(b); BIO_clear_retry_flags(b);
CHECK(buf != nullptr);
return narrow_cast<int>(stream->flow_write(Slice(buf, len))); return narrow_cast<int>(stream->flow_write(Slice(buf, len)));
} }
} // namespace } // namespace

View File

@ -45,7 +45,7 @@ class ParserImpl {
return ptr_ == end_; return ptr_ == end_;
} }
void clear() { void clear() {
ptr_ = nullptr; ptr_ = SliceT().begin();
end_ = ptr_; end_ = ptr_;
status_ = Status::OK(); status_ = Status::OK();
} }