mirror of
https://github.com/xmrig/xmrig.git
synced 2025-01-22 18:54:43 +00:00
#2207 Fixed regression in HTTP parser.
This commit is contained in:
parent
3c6077fb02
commit
30cfcc27db
5 changed files with 7 additions and 14 deletions
|
@ -119,7 +119,7 @@ void xmrig::HttpClient::handshake()
|
|||
|
||||
void xmrig::HttpClient::read(const char *data, size_t size)
|
||||
{
|
||||
if (parse(data, size) < size) {
|
||||
if (!parse(data, size)) {
|
||||
close(UV_EPROTO);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,13 +118,13 @@ bool xmrig::HttpContext::isRequest() const
|
|||
}
|
||||
|
||||
|
||||
size_t xmrig::HttpContext::parse(const char *data, size_t size)
|
||||
bool xmrig::HttpContext::parse(const char *data, size_t size)
|
||||
{
|
||||
if (size == 0) {
|
||||
return size;
|
||||
return true;
|
||||
}
|
||||
|
||||
return llhttp_execute(m_parser, data, size);
|
||||
return llhttp_execute(m_parser, data, size) == HPE_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
void write(std::string &&data, bool close) override;
|
||||
|
||||
bool isRequest() const override;
|
||||
size_t parse(const char *data, size_t size);
|
||||
bool parse(const char *data, size_t size);
|
||||
std::string ip() const override;
|
||||
uint64_t elapsed() const;
|
||||
void close(int status = 0);
|
||||
|
|
|
@ -50,14 +50,7 @@ void xmrig::HttpServer::onConnection(uv_stream_t *stream, uint16_t)
|
|||
{
|
||||
auto ctx = static_cast<HttpContext*>(tcp->data);
|
||||
|
||||
if (nread >= 0) {
|
||||
const auto size = static_cast<size_t>(nread);
|
||||
const auto parsed = ctx->parse(buf->base, size);
|
||||
|
||||
if (parsed < size) {
|
||||
ctx->close();
|
||||
}
|
||||
} else {
|
||||
if (nread < 0 || !ctx->parse(buf->base, static_cast<size_t>(nread))) {
|
||||
ctx->close();
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ bool xmrig::HttpsContext::write(BIO *bio)
|
|||
|
||||
void xmrig::HttpsContext::parse(char *data, size_t size)
|
||||
{
|
||||
if (HttpContext::parse(data, size) < size) {
|
||||
if (!HttpContext::parse(data, size)) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue