Skip to content

Commit 8cdc6c8

Browse files
rootjengelh
authored andcommitted
http: clear GSS state on anything but GSS_C_CONTINUE_NEEDED
References: GXF-1789, DESK-2497
1 parent 17d1ff8 commit 8cdc6c8

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

exch/http/http_parser.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,8 @@ int http_parser::auth_krb(http_context &ctx, const char *input, size_t isize,
10561056
OM_uint32 status{};
10571057
gss_name_t gss_srv_name{}, gss_username{};
10581058
gss_buffer_desc gss_input_buf{}, gss_user_buf{}, gss_output_token{};
1059-
auto cl_0 = HX::make_scope_exit([&]() {
1059+
auto cl_0 = HX::make_scope_exit([&]() { ctx.clear_gss(); });
1060+
auto cl_1 = HX::make_scope_exit([&]() {
10601061
if (gss_output_token.length != 0)
10611062
gss_release_buffer(&status, &gss_output_token);
10621063
if (gss_user_buf.length != 0)
@@ -1101,8 +1102,10 @@ int http_parser::auth_krb(http_context &ctx, const char *input, size_t isize,
11011102
else
11021103
output.clear();
11031104

1104-
if (ret == GSS_S_CONTINUE_NEEDED)
1105+
if (ret == GSS_S_CONTINUE_NEEDED) {
1106+
cl_0.release(); /* keep state for next round */
11051107
return -99; /* MOAR */
1108+
}
11061109
output.clear();
11071110
if (ret != GSS_S_COMPLETE) {
11081111
krblog("Unable to accept security context", ret, status);
@@ -2309,16 +2312,25 @@ static void http_parser_context_clear(HTTP_CONTEXT *pcontext)
23092312
mod_fastcgi_insert_ctx(pcontext);
23102313
}
23112314

2312-
http_context::~http_context()
2315+
void http_context::clear_gss()
23132316
{
2314-
auto pcontext = this;
23152317
#ifdef HAVE_GSSAPI
23162318
OM_uint32 st;
2317-
if (m_gss_srv_creds != nullptr)
2319+
if (m_gss_srv_creds != nullptr) {
23182320
gss_release_cred(&st, &m_gss_srv_creds);
2319-
if (m_gss_ctx != nullptr)
2321+
m_gss_srv_creds = GSS_C_NO_CREDENTIAL;
2322+
}
2323+
if (m_gss_ctx != nullptr) {
23202324
gss_delete_sec_context(&st, &m_gss_ctx, GSS_C_NO_BUFFER);
2325+
m_gss_ctx = GSS_C_NO_CONTEXT;
2326+
}
23212327
#endif
2328+
}
2329+
2330+
http_context::~http_context()
2331+
{
2332+
auto pcontext = this;
2333+
clear_gss();
23222334
if (hpm_processor_is_in_charge(pcontext))
23232335
hpm_processor_insert_ctx(pcontext);
23242336
else if (mod_fastcgi_is_in_charge(pcontext))

exch/http/http_parser.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ struct http_context final : public schedule_context {
5252
http_context();
5353
~http_context();
5454
NOMOVE(http_context);
55+
void clear_gss();
56+
5557
BOOL try_create_vconnection();
5658
void set_outchannel_flowcontrol(uint32_t bytes_received, uint32_t available_window);
5759
BOOL recycle_inchannel(const char *predecessor_cookie);

0 commit comments

Comments
 (0)