unbalanced WSAStartup/WSACleanup calls
Zvika Meiseles
zvika.meiseles at gmail.com
Tue May 5 13:18:11 EDT 2026
Hi,
I suspect the krb5 code may execute unbalanced WSAStartup/WSACleanup calls,
causing premature WinSock cleanup and application crash (following a crash
I'm investigating where krb5 context cleanup causes WinSock destruction).
I wanted to run this by the group before submitting a bug report, just to
make sure I'm not imagining things.
The code in question is in src\lib\krb5\os\init_os_ctx.c and
src\lib\krb5\krb\init_ctx.c :
When a context is created, after it is successfully allocated in
krb5_init_context_profile, k5_os_init_context is called, which in turn may
call WSAStartup, and that call may also fail.
However, from this point forward, any failure will cause a jump to :cleanup
and a call to krb5_free_context. It will, in turn, call WSACleanup since
ctx is not null (it is only nullified in the success path).
I think we need to add a flag tracking whether WSAStartup was
(successfully) called, and only then call WSACleanup.
WDYT?
Zvika
More information about the krbdev
mailing list