unbalanced WSAStartup/WSACleanup calls
Zvika Meiseles <[email protected]> Tue, 5 May 2026 20:18:11 +0300
| Newsgroups | gmane.comp.encryption.kerberos.devel |
|---|---|
| Message-ID | <CAGNA6=HUKvYaQqseJocg1UjFkB0+WvAzL3BmnpkeZgz_wSdNfQ@mail.gmail.com> |
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 [email protected] https://mailman.mit.edu/mailman/listinfo/krbdev