[multiple] reset http vers, avoid rare crash (fixes #3152)

(thx ultimator)

do not set r->http_version to HTTP_VERSION_2 when selecting TLS ALPN
if r->handler_module already set, since handler module is likely
mod_sockproxy, and con->h2 will not get initialized.

This does continue to select "h2", so the mod_sockproxy backend
should be prepared to receive the HTTP/2 client connection preface.

x-ref:
  "Random Segfaults with version 1.4.64 w/ mod_sockproxy and ALPN h2"
  https://redmine.lighttpd.net/issues/3152
master
Glenn Strauss 10 months ago
parent 1ed3a78ea9
commit fbade1850f

@ -1406,7 +1406,8 @@ mod_gnutls_ALPN (handler_ctx * const hctx, const unsigned char * const in, const
if (in[i] == 'h' && in[i+1] == '2') {
if (!hctx->r->conf.h2proto) continue;
hctx->alpn = MOD_GNUTLS_ALPN_H2;
hctx->r->http_version = HTTP_VERSION_2;
if (hctx->r->handler_module == NULL)/*(e.g. not mod_sockproxy)*/
hctx->r->http_version = HTTP_VERSION_2;
return GNUTLS_E_SUCCESS;
}
continue;

@ -1202,7 +1202,8 @@ mod_mbedtls_alpn_selected (handler_ctx * const hctx, const char * const in)
case 2: /* "h2" */
if (in[i] == 'h' && in[i+1] == '2') {
proto = MOD_MBEDTLS_ALPN_H2;
hctx->r->http_version = HTTP_VERSION_2;
if (hctx->r->handler_module == NULL)/*(e.g. not mod_sockproxy)*/
hctx->r->http_version = HTTP_VERSION_2;
break;
}
return 0;
@ -1247,7 +1248,8 @@ mod_mbedtls_alpn_select_cb (handler_ctx *hctx, const unsigned char *in, const un
if (in[i] == 'h' && in[i+1] == '2') {
if (!hctx->r->conf.h2proto) continue;
hctx->alpn = MOD_MBEDTLS_ALPN_H2;
hctx->r->http_version = HTTP_VERSION_2;
if (hctx->r->handler_module == NULL)/*(e.g. not mod_sockproxy)*/
hctx->r->http_version = HTTP_VERSION_2;
return 0;
}
continue;

@ -1367,7 +1367,8 @@ mod_nss_alpn_select_cb (void *arg, PRFileDesc *ssl,
case 0:
if (!hctx->r->conf.h2proto) continue;
hctx->alpn = MOD_NSS_ALPN_H2;
hctx->r->http_version = HTTP_VERSION_2;
if (hctx->r->handler_module == NULL)/*(not mod_sockproxy)*/
hctx->r->http_version = HTTP_VERSION_2;
break;
case 1:
hctx->alpn = MOD_NSS_ALPN_HTTP11;

@ -1883,7 +1883,8 @@ mod_openssl_alpn_select_cb (SSL *ssl, const unsigned char **out, unsigned char *
if (in[i] == 'h' && in[i+1] == '2') {
if (!hctx->r->conf.h2proto) continue;
proto = MOD_OPENSSL_ALPN_H2;
hctx->r->http_version = HTTP_VERSION_2;
if (hctx->r->handler_module == NULL)/*(e.g. not mod_sockproxy)*/
hctx->r->http_version = HTTP_VERSION_2;
break;
}
continue;

@ -1823,7 +1823,8 @@ mod_openssl_alpn_select_cb (SSL *ssl, const unsigned char **out, unsigned char *
if (in[i] == 'h' && in[i+1] == '2') {
if (!hctx->r->conf.h2proto) continue;
proto = MOD_OPENSSL_ALPN_H2;
hctx->r->http_version = HTTP_VERSION_2;
if (hctx->r->handler_module == NULL)/*(e.g. not mod_sockproxy)*/
hctx->r->http_version = HTTP_VERSION_2;
break;
}
continue;

Loading…
Cancel
Save