nghttpx: Check that HTTP response message finished safely

This commit is contained in:
Tatsuhiro Tsujikawa 2021-09-16 22:00:36 +09:00
parent f3b9cd8404
commit e167e07a9a
1 changed files with 24 additions and 0 deletions

View File

@ -1218,6 +1218,18 @@ int HttpDownstreamConnection::read_clear() {
} }
if (nread < 0) { if (nread < 0) {
if (nread == SHRPX_ERR_EOF && !downstream_->get_upgraded()) {
auto htperr = llhttp_finish(&response_htp_);
if (htperr != HPE_OK) {
if (LOG_ENABLED(INFO)) {
DCLOG(INFO, this) << "HTTP response ended prematurely: "
<< llhttp_errno_name(htperr);
}
return -1;
}
}
return nread; return nread;
} }
@ -1337,6 +1349,18 @@ int HttpDownstreamConnection::read_tls() {
} }
if (nread < 0) { if (nread < 0) {
if (nread == SHRPX_ERR_EOF && !downstream_->get_upgraded()) {
auto htperr = llhttp_finish(&response_htp_);
if (htperr != HPE_OK) {
if (LOG_ENABLED(INFO)) {
DCLOG(INFO, this) << "HTTP response ended prematurely: "
<< llhttp_errno_name(htperr);
}
return -1;
}
}
return nread; return nread;
} }