krb5 commit: Fix exported name length check on 32-bit platforms

ghudson at mit.edu ghudson at mit.edu
Sat Nov 21 03:34:46 EST 2026


https://github.com/krb5/krb5/commit/ef4d3f9874f81d84e975dac636e3bcc98f49e407
commit ef4d3f9874f81d84e975dac636e3bcc98f49e407
Author: ubeddulla khan <ubed at bugqore.com>
Date:   Sat Nov 21 02:11:35 2026 +0530

    Fix exported name length check on 32-bit platforms
    
    In the krb5 mech's import_name(), store the exported name length in a
    size_t and compare it against the remaining input as unsigned.  On
    platforms with a 32-bit ssize_t, a name length of 0xFFFFFFFF was read
    as -1, passed the bounds check, and caused a heap buffer overrun.
    
    ticket: 9295 (new)
    tags: pullup
    target_version: 1.22-next

 src/lib/gssapi/krb5/import_name.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/lib/gssapi/krb5/import_name.c b/src/lib/gssapi/krb5/import_name.c
index 9a27b1468..842d804fc 100644
--- a/src/lib/gssapi/krb5/import_name.c
+++ b/src/lib/gssapi/krb5/import_name.c
@@ -129,7 +129,7 @@ import_name(OM_uint32 *minor_status, gss_buffer_t input_name_buffer,
     krb5_error_code code;
     unsigned char *cp, *end;
     char *tmp = NULL, *tmp2 = NULL, *service = NULL, *host = NULL, *stringrep;
-    ssize_t    length;
+    size_t     length;
 #ifndef NO_PASSWORD
     struct passwd *pw;
 #endif
@@ -231,7 +231,7 @@ import_name(OM_uint32 *minor_status, gss_buffer_t input_name_buffer,
         } else if (g_OID_equal(input_name_type, gss_nt_exported_name) ||
                    g_OID_equal(input_name_type, GSS_C_NT_COMPOSITE_EXPORT)) {
 #define BOUNDS_CHECK(cp, end, n)                                        \
-            do { if ((end) - (cp) < (n)) goto fail_name; } while (0)
+            do { if ((size_t)((end) - (cp)) < (n)) goto fail_name; } while (0)
             cp = (unsigned char *)tmp;
             end = cp + input_name_buffer->length;
 
@@ -252,14 +252,14 @@ import_name(OM_uint32 *minor_status, gss_buffer_t input_name_buffer,
             if (*cp++ != 0x00)
                 goto fail_name;
             length = *cp++;
-            if (length != (ssize_t)gss_mech_krb5->length+2)
+            if (length != gss_mech_krb5->length + 2)
                 goto fail_name;
 
             BOUNDS_CHECK(cp, end, 2);
             if (*cp++ != 0x06)
                 goto fail_name;
             length = *cp++;
-            if (length != (ssize_t)gss_mech_krb5->length)
+            if (length != gss_mech_krb5->length)
                 goto fail_name;
 
             BOUNDS_CHECK(cp, end, length);


More information about the cvs-krb5 mailing list