>From a7f5207c328c737a19f0a8c3116a25db46daa980 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Thu, 31 May 2012 19:28:29 +0200 Subject: [PATCH 07/11] 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 | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/providers/krb5/krb5_utils.c b/src/providers/krb5/krb5_utils.c index c97d58e7c7cfb80b3fd34eaf18a5371669871272..9fe1420281c39ba122491eeda5cefe8e298fb1e0 100644 --- a/src/providers/krb5/krb5_utils.c +++ b/src/providers/krb5/krb5_utils.c @@ -285,14 +285,17 @@ 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'; + + 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); -- 1.7.10.2