krb5 commit: Prevent read overrun in update_ldap_mod_auth_ind()

ghudson at mit.edu ghudson at mit.edu
Sat Nov 21 02:55:30 EST 2026


https://github.com/krb5/krb5/commit/efc55a5664eb38f4d9cf804e4b869de303504369
commit efc55a5664eb38f4d9cf804e4b869de303504369
Author: ubeddulla khan <ubed at bugqore.com>
Date:   Wed Nov 18 13:16:20 2026 +0530

    Prevent read overrun in update_ldap_mod_auth_ind()
    
    In update_ldap_mod_auth_ind(), ensure that the strval array remains
    null-terminated if the maximum number of indicators are read.
    
    [ghudson at mit.edu: edited commit message and test case comment]
    
    ticket: 9294 (new)
    tags: pullup
    target_version: 1.22-next

 src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c | 5 +++--
 src/tests/t_kdb.py                                 | 8 ++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c
index dfdd96ab7..cb588ed66 100644
--- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c
+++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c
@@ -669,7 +669,7 @@ update_ldap_mod_auth_ind(krb5_context context, krb5_db_entry *entry,
 {
     krb5_error_code ret;
     char *auth_ind = NULL;
-    char *strval[10] = { 0 };
+    char *strval[11] = { 0 };
     char *ai, *ai_save = NULL;
     size_t i = 0, sv_num = sizeof(strval) / sizeof(*strval);
     int mask;
@@ -689,8 +689,9 @@ update_ldap_mod_auth_ind(krb5_context context, krb5_db_entry *entry,
         return 0;
     }
 
+    /* Leave room for a null terminator in strval. */
     ai = strtok_r(auth_ind, " ", &ai_save);
-    while (ai != NULL && i < sv_num) {
+    while (ai != NULL && i < sv_num - 1) {
         strval[i++] = ai;
         ai = strtok_r(NULL, " ", &ai_save);
     }
diff --git a/src/tests/t_kdb.py b/src/tests/t_kdb.py
index afc683cb9..a9aa07197 100755
--- a/src/tests/t_kdb.py
+++ b/src/tests/t_kdb.py
@@ -356,6 +356,14 @@ out = realm.run([kadminl, 'getstrs', 'authind'])
 if 'require_auth' in out:
     fail('require_auth string attribute still visible after delstr')
 
+# Regression test for #9294: store ten required auth indicators and
+# verify that exactly those indicators are read back.
+realm.run([kadminl, 'setstr', 'authind', 'require_auth',
+           'a b c d e f g h i j'])
+out = realm.run([kadminl, 'getstrs', 'authind'])
+if 'require_auth: a b c d e f g h i j\n' not in out:
+    fail('Expected require_auth value not in getstrs output')
+
 mark('LDAP service principal aliases')
 
 # Test service principal aliases.


More information about the cvs-krb5 mailing list