nghttpx: Fix error found by coverity scan
This commit is contained in:
parent
4430b06c71
commit
e583a25a8b
14
src/shrpx.cc
14
src/shrpx.cc
|
@ -205,6 +205,7 @@ create_unix_domain_acceptor(ConnectionHandler *handler) {
|
||||||
if (pathlen + 1 > sizeof(addr.un.sun_path)) {
|
if (pathlen + 1 > sizeof(addr.un.sun_path)) {
|
||||||
LOG(FATAL) << "UNIX domain socket path " << path << " is too long > "
|
LOG(FATAL) << "UNIX domain socket path " << path << " is too long > "
|
||||||
<< sizeof(addr.un.sun_path);
|
<< sizeof(addr.un.sun_path);
|
||||||
|
close(fd);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
// copy path including terminal NULL
|
// copy path including terminal NULL
|
||||||
|
@ -213,8 +214,17 @@ create_unix_domain_acceptor(ConnectionHandler *handler) {
|
||||||
// unlink (remove) already existing UNIX domain socket path
|
// unlink (remove) already existing UNIX domain socket path
|
||||||
unlink(path);
|
unlink(path);
|
||||||
|
|
||||||
if (bind(fd, &addr.sa, sizeof(addr.un)) != 0 ||
|
if (bind(fd, &addr.sa, sizeof(addr.un)) != 0) {
|
||||||
listen(fd, get_config()->backlog) != 0) {
|
auto error = errno;
|
||||||
|
LOG(FATAL) << "Failed to bind UNIX domain socket, error=" << error;
|
||||||
|
close(fd);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listen(fd, get_config()->backlog) != 0) {
|
||||||
|
auto error = errno;
|
||||||
|
LOG(FATAL) << "Failed to listen to UNIX domain socket, error=" << error;
|
||||||
|
close(fd);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -406,14 +406,13 @@ http_parser_settings htp_hooks = {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int Http2Session::downstream_read_proxy() {
|
int Http2Session::downstream_read_proxy() {
|
||||||
for (;;) {
|
|
||||||
if (rb_.rleft() == 0) {
|
if (rb_.rleft() == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t nread = http_parser_execute(proxy_htp_.get(), &htp_hooks,
|
size_t nread =
|
||||||
reinterpret_cast<const char *>(rb_.pos),
|
http_parser_execute(proxy_htp_.get(), &htp_hooks,
|
||||||
rb_.rleft());
|
reinterpret_cast<const char *>(rb_.pos), rb_.rleft());
|
||||||
|
|
||||||
rb_.drain(nread);
|
rb_.drain(nread);
|
||||||
|
|
||||||
|
@ -447,7 +446,6 @@ int Http2Session::downstream_read_proxy() {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int Http2Session::downstream_connect_proxy() {
|
int Http2Session::downstream_connect_proxy() {
|
||||||
if (LOG_ENABLED(INFO)) {
|
if (LOG_ENABLED(INFO)) {
|
||||||
|
|
Loading…
Reference in New Issue