nghttp: Fix crash on plain HTTP
This commit is contained in:
parent
0fb4d32d6a
commit
ecc4290d3d
|
@ -1313,36 +1313,38 @@ void eventcb(bufferevent *bev, short events, void *ptr)
|
||||||
if(client->need_upgrade()) {
|
if(client->need_upgrade()) {
|
||||||
rv = client->on_upgrade_connect();
|
rv = client->on_upgrade_connect();
|
||||||
} else {
|
} else {
|
||||||
// Check NPN or ALPN result
|
if(client->ssl) {
|
||||||
const unsigned char *next_proto = nullptr;
|
// Check NPN or ALPN result
|
||||||
unsigned int next_proto_len;
|
const unsigned char *next_proto = nullptr;
|
||||||
SSL_get0_next_proto_negotiated(client->ssl,
|
unsigned int next_proto_len;
|
||||||
&next_proto, &next_proto_len);
|
SSL_get0_next_proto_negotiated(client->ssl,
|
||||||
for(int i = 0; i < 2; ++i) {
|
&next_proto, &next_proto_len);
|
||||||
if(next_proto) {
|
for(int i = 0; i < 2; ++i) {
|
||||||
if(config.verbose) {
|
if(next_proto) {
|
||||||
std::cout << "The negotiated protocol: ";
|
if(config.verbose) {
|
||||||
std::cout.write(reinterpret_cast<const char*>(next_proto),
|
std::cout << "The negotiated protocol: ";
|
||||||
next_proto_len);
|
std::cout.write(reinterpret_cast<const char*>(next_proto),
|
||||||
std::cout << std::endl;
|
next_proto_len);
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
if(NGHTTP2_PROTO_VERSION_ID_LEN != next_proto_len ||
|
||||||
|
memcmp(NGHTTP2_PROTO_VERSION_ID, next_proto,
|
||||||
|
NGHTTP2_PROTO_VERSION_ID_LEN) != 0) {
|
||||||
|
next_proto = nullptr;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if(NGHTTP2_PROTO_VERSION_ID_LEN != next_proto_len ||
|
|
||||||
memcmp(NGHTTP2_PROTO_VERSION_ID, next_proto,
|
|
||||||
NGHTTP2_PROTO_VERSION_ID_LEN) != 0) {
|
|
||||||
next_proto = nullptr;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
|
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
|
||||||
SSL_get0_alpn_selected(client->ssl, &next_proto, &next_proto_len);
|
SSL_get0_alpn_selected(client->ssl, &next_proto, &next_proto_len);
|
||||||
#else // OPENSSL_VERSION_NUMBER < 0x10002000L
|
#else // OPENSSL_VERSION_NUMBER < 0x10002000L
|
||||||
break;
|
break;
|
||||||
#endif // OPENSSL_VERSION_NUMBER < 0x10002000L
|
#endif // OPENSSL_VERSION_NUMBER < 0x10002000L
|
||||||
}
|
}
|
||||||
if(!next_proto) {
|
if(!next_proto) {
|
||||||
print_protocol_nego_error();
|
print_protocol_nego_error();
|
||||||
client->disconnect();
|
client->disconnect();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rv = client->on_connect();
|
rv = client->on_connect();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue