From 7b9f1e13c750fed76886513071a2b63949181ea4 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Thu, 31 May 2012 19:28:29 +0200 Subject: Handle trailing slash in the ccname template With the DIR cache support, it's perfectly legal to specify a ccname directory that ends with a slash. The create_dir function did not handle that situation correctly. --- src/providers/krb5/krb5_utils.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/providers/krb5') diff --git a/src/providers/krb5/krb5_utils.c b/src/providers/krb5/krb5_utils.c index c97d58e7..9d199e1f 100644 --- a/src/providers/krb5/krb5_utils.c +++ b/src/providers/krb5/krb5_utils.c @@ -285,14 +285,20 @@ static errno_t find_ccdir_parent_data(TALLOC_CTX *mem_ctx, const char *dirname, DEBUG(1, ("talloc_strdup failed.\n")); return ENOMEM; } - end = strrchr(parent, '/'); - if (end == NULL || end == parent) { - DEBUG(1, ("Cannot find parent directory of [%s], / is not allowed.\n", - dirname)); - ret = EINVAL; - goto done; - } - *end = '\0'; + + /* We'll remove all trailing slashes from the back so that + * we only pass /some/path to find_ccdir_parent_data, not + * /some/path */ + do { + end = strrchr(parent, '/'); + if (end == NULL || end == parent) { + DEBUG(1, ("Cannot find parent directory of [%s], / is not allowed.\n", + dirname)); + ret = EINVAL; + goto done; + } + *end = '\0'; + } while (*(end+1) == '\0'); ret = find_ccdir_parent_data(mem_ctx, parent, parent_stat, missing_parents); -- cgit