My issue:
I noticed that ngx_ssl_get_protocol() and ngx_ssl_get_cipher_name() only assign the static pointer returned by OpenSSL to s->data, leaving s->len completely untouched (which remains 0 if initialized with ngx_str_null, or garbage if allocated on the stack):
Is there any historical reason or architectural consideration behind leaving s->len uninitialized in these specific functions?
ngx_int_t
ngx_ssl_get_protocol(ngx_connection_t *c, ngx_pool_t *pool, ngx_str_t *s)
{
s->data = (u_char *) SSL_get_version(c->ssl->connection);
return NGX_OK;
}
ngx_int_t
ngx_ssl_get_cipher_name(ngx_connection_t *c, ngx_pool_t *pool, ngx_str_t *s)
{
s->data = (u_char *) SSL_get_cipher_name(c->ssl->connection);
return NGX_OK;
}
How I encountered the problem:
Solutions I’ve tried:
Add ngx_strlen().
Version of NGINX or NGINX adjacent software (e.g. NGINX Gateway Fabric):
nginx-1.31.1
Deployment environment:
ubuntu