[20570] in Kerberos_V5_Development
unbalanced WSAStartup/WSACleanup calls
daemon@ATHENA.MIT.EDU (Zvika Meiseles)
Tue May 5 13:18:31 2026
MIME-Version: 1.0
From: Zvika Meiseles <zvika.meiseles@gmail.com>
Date: Tue, 5 May 2026 20:18:11 +0300
Message-ID: <CAGNA6=HUKvYaQqseJocg1UjFkB0+WvAzL3BmnpkeZgz_wSdNfQ@mail.gmail.com>
To: krbdev@mit.edu
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: krbdev-bounces@mit.edu
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
_______________________________________________
krbdev mailing list krbdev@mit.edu
https://mailman.mit.edu/mailman/listinfo/krbdev