[31539] in CVS-changelog-for-Kerberos-V5

home help back first fref pref prev next nref lref last post

krb5 commit: Avoid asymmetric WSACleanup() in libkrb5

daemon@ATHENA.MIT.EDU (ghudson@mit.edu)
Wed May 27 18:53:06 2026

From: ghudson@mit.edu
To: cvs-krb5@mit.edu
Message-Id: <20260527225300.C8466102BE3@krbdev.mit.edu>
Date: Wed, 27 May 2026 18:53:00 -0400 (EDT)
MIME-Version: 1.0
Reply-To: krbdev@mit.edu
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cvs-krb5-bounces@mit.edu

https://github.com/krb5/krb5/commit/acf38f87c07f873c13ec2f51442519e16f1c3512
commit acf38f87c07f873c13ec2f51442519e16f1c3512
Author: Greg Hudson <ghudson@mit.edu>
Date:   Mon May 18 12:27:52 2026 -0400

    Avoid asymmetric WSACleanup() in libkrb5
    
    In k5_os_init_context(), call WSAStartup() before doing anything else.
    Otherwise, a failure to read or parse krb5.conf could cause an
    asymmetric call to WSACleanup() in k5_os_free_context().  Reported by
    Zvika Meiseles.
    
    ticket: 9210 (new)
    tags: pullup
    target_version: 1.22-next

 src/lib/krb5/os/init_os_ctx.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/src/lib/krb5/os/init_os_ctx.c b/src/lib/krb5/os/init_os_ctx.c
index c35007888..2d9951186 100644
--- a/src/lib/krb5/os/init_os_ctx.c
+++ b/src/lib/krb5/os/init_os_ctx.c
@@ -416,8 +416,11 @@ k5_os_init_context(krb5_context ctx, profile_t profile, krb5_flags flags)
     krb5_os_context os_ctx;
     krb5_error_code    retval = 0;
 #ifdef _WIN32
-    WORD wVersionRequested;
     WSADATA wsaData;
+
+    /* Initialize winsock to version 1.1.  Do this first so that we know it was
+     * done in k5_os_free_context(), and can safely call WSACleanup(). */
+    WSAStartup(0x0101, &wsaData);
 #endif /* _WIN32 */
 
     os_ctx = &ctx->os_context;
@@ -438,14 +441,6 @@ k5_os_init_context(krb5_context ctx, profile_t profile, krb5_flags flags)
     if (retval)
         return retval;
 
-#ifdef _WIN32
-    /* We initialize winsock to version 1.1 but
-     * we do not care if we succeed or fail.
-     */
-    wVersionRequested = 0x0101;
-    WSAStartup (wVersionRequested, &wsaData);
-#endif /* _WIN32 */
-
     return 0;
 }
 
_______________________________________________
cvs-krb5 mailing list
cvs-krb5@mit.edu
https://mailman.mit.edu/mailman/listinfo/cvs-krb5

home help back first fref pref prev next nref lref last post