>From ee925752e95af4e29906603e960350f0592c88c8 Mon Sep 17 00:00:00 2001 From: Bogdan Boguslavskij Date: Mon, 16 Nov 2026 17:30:53 +0300 Subject: [PATCH] Avoid OOB read in DIR primary file parsing In read_primary_file(), check len before indexing buf[len - 1], avoiding a read before the buffer when the primary file begins with a zero byte. --- src/lib/krb5/ccache/cc_dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/krb5/ccache/cc_dir.c b/src/lib/krb5/ccache/cc_dir.c index 1da40b51d..7bcef4ee6 100644 --- a/src/lib/krb5/ccache/cc_dir.c +++ b/src/lib/krb5/ccache/cc_dir.c @@ -164,7 +164,7 @@ read_primary_file(krb5_context context, const char *primary_path, /* Check if line is too long, doesn't look like a subsidiary cache * filename, or isn't a single-component filename. */ - if (buf[len - 1] != '\n' || !filename_is_cache(buf) || + if (len == 0 || buf[len - 1] != '\n' || !filename_is_cache(buf) || strchr(buf, '/') || strchr(buf, '\\')) { k5_setmsg(context, KRB5_CC_FORMAT, _("%s contains invalid filename"), primary_path); -- 2.50.1