>From 9c04e6be766054c1ae593c584b39ae6d814fa026 Mon Sep 17 00:00:00 2001 From: Bogdan Boguslavskij Date: Mon, 16 Nov 2026 17:17:47 +0300 Subject: [PATCH] Avoid OOB read for short default ccache names In fcc_ptcursor_next(), check that the default cache name contains at least two characters before skipping a possible drive prefix. This avoids reading beyond the string terminator for empty or one-character names. --- src/lib/krb5/ccache/cc_file.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/krb5/ccache/cc_file.c b/src/lib/krb5/ccache/cc_file.c index f34c0f106..3f6b2dc66 100644 --- a/src/lib/krb5/ccache/cc_file.c +++ b/src/lib/krb5/ccache/cc_file.c @@ -1221,10 +1221,11 @@ fcc_ptcursor_next(krb5_context context, krb5_cc_ptcursor cursor, if (!defname) return 0; - /* Check if the default has type FILE or no type; find the residual. */ + /* Check if the default has type FILE or no type (skipping a drive prefix + * if any); find the residual. */ if (strncmp(defname, "FILE:", 5) == 0) residual = defname + 5; - else if (strchr(defname + 2, ':') == NULL) /* Skip drive prefix if any. */ + else if (strlen(defname) < 2 || strchr(defname + 2, ':') == NULL) residual = defname; else return 0; -- 2.50.1