Increase MAX_CONTENT_SIZE in HttpReader.
This commit is contained in:
parent
916a5f5848
commit
103c6ad1e8
@ -46,12 +46,12 @@ bool HttpChunkedByteFlow::loop() {
|
|||||||
set_need_size(need_size);
|
set_need_size(need_size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
total_size_ += ready;
|
if (total_size_ > MAX_SIZE - ready) {
|
||||||
uncommited_size_ += ready;
|
|
||||||
if (total_size_ > MAX_SIZE) {
|
|
||||||
finish(Status::Error(PSLICE() << "Too big query " << tag("size", input_->size())));
|
finish(Status::Error(PSLICE() << "Too big query " << tag("size", input_->size())));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
total_size_ += ready;
|
||||||
|
uncommited_size_ += ready;
|
||||||
|
|
||||||
output_.append(input_->cut_head(ready));
|
output_.append(input_->cut_head(ready));
|
||||||
result = true;
|
result = true;
|
||||||
|
@ -17,8 +17,8 @@ class HttpChunkedByteFlow final : public ByteFlowBase {
|
|||||||
bool loop() final;
|
bool loop() final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr int MAX_CHUNK_SIZE = 15 << 20; // some reasonable limit
|
static constexpr size_t MAX_CHUNK_SIZE = 15 << 20; // some reasonable limit
|
||||||
static constexpr int MAX_SIZE = std::numeric_limits<int32>::max(); // some reasonable limit
|
static constexpr size_t MAX_SIZE = std::numeric_limits<uint32>::max(); // some reasonable limit
|
||||||
static constexpr size_t MIN_UPDATE_SIZE = 1 << 14;
|
static constexpr size_t MIN_UPDATE_SIZE = 1 << 14;
|
||||||
enum class State { ReadChunkLength, ReadChunkContent, OK };
|
enum class State { ReadChunkLength, ReadChunkContent, OK };
|
||||||
State state_ = State::ReadChunkLength;
|
State state_ = State::ReadChunkLength;
|
||||||
|
@ -103,7 +103,7 @@ Result<size_t> HttpReader::read_next(HttpQuery *query, bool can_be_slow) {
|
|||||||
*source >> flow_sink_;
|
*source >> flow_sink_;
|
||||||
content_ = flow_sink_.get_output();
|
content_ = flow_sink_.get_output();
|
||||||
|
|
||||||
if (content_length_ > MAX_CONTENT_SIZE) {
|
if (content_length_ >= MAX_CONTENT_SIZE) {
|
||||||
return Status::Error(413, PSLICE() << "Request Entity Too Large: content length is " << content_length_);
|
return Status::Error(413, PSLICE() << "Request Entity Too Large: content length is " << content_length_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -558,7 +558,11 @@ void HttpReader::process_header(MutableSlice header_name, MutableSlice header_va
|
|||||||
// TODO: check if protocol is HTTP/1.1
|
// TODO: check if protocol is HTTP/1.1
|
||||||
query_->keep_alive_ = true;
|
query_->keep_alive_ = true;
|
||||||
if (header_name == "content-length") {
|
if (header_name == "content-length") {
|
||||||
content_length_ = to_integer<size_t>(header_value);
|
auto content_length = to_integer<uint64>(header_value);
|
||||||
|
if (content_length > MAX_CONTENT_SIZE) {
|
||||||
|
content_length = MAX_CONTENT_SIZE;
|
||||||
|
}
|
||||||
|
content_length_ = static_cast<size_t>(content_length);
|
||||||
} else if (header_name == "connection") {
|
} else if (header_name == "connection") {
|
||||||
to_lower_inplace(header_value);
|
to_lower_inplace(header_value);
|
||||||
if (header_value == "close") {
|
if (header_value == "close") {
|
||||||
|
@ -101,11 +101,11 @@ class HttpReader {
|
|||||||
void close_temp_file();
|
void close_temp_file();
|
||||||
void clean_temporary_file();
|
void clean_temporary_file();
|
||||||
|
|
||||||
static constexpr size_t MAX_CONTENT_SIZE = std::numeric_limits<int32>::max(); // Some reasonable limit
|
static constexpr size_t MAX_CONTENT_SIZE = std::numeric_limits<uint32>::max(); // Some reasonable limit
|
||||||
static constexpr size_t MAX_TOTAL_PARAMETERS_LENGTH = 1 << 20; // Some reasonable limit
|
static constexpr size_t MAX_TOTAL_PARAMETERS_LENGTH = 1 << 20; // Some reasonable limit
|
||||||
static constexpr size_t MAX_TOTAL_HEADERS_LENGTH = 1 << 18; // Some reasonable limit
|
static constexpr size_t MAX_TOTAL_HEADERS_LENGTH = 1 << 18; // Some reasonable limit
|
||||||
static constexpr size_t MAX_BOUNDARY_LENGTH = 70; // As defined by RFC1341
|
static constexpr size_t MAX_BOUNDARY_LENGTH = 70; // As defined by RFC1341
|
||||||
static constexpr int64 MAX_FILE_SIZE = static_cast<int64>(4000) << 20; // Telegram server file size limit
|
static constexpr int64 MAX_FILE_SIZE = static_cast<int64>(4000) << 20; // Telegram server file size limit
|
||||||
static constexpr const char TEMP_DIRECTORY_PREFIX[] = "tdlib-server-tmp";
|
static constexpr const char TEMP_DIRECTORY_PREFIX[] = "tdlib-server-tmp";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user