simplify maildir recursion limitation
the isDir argument is effectively already a depth counter, so we don't
need a separate one for that.
amends 79797826
.
This commit is contained in:
parent
52c063fd45
commit
32d500ed15
|
@ -367,7 +367,7 @@ static int maildir_list_inbox( maildir_store_t *ctx, int flags, const char *base
|
||||||
static int maildir_list_path( maildir_store_t *ctx, int flags, const char *inbox );
|
static int maildir_list_path( maildir_store_t *ctx, int flags, const char *inbox );
|
||||||
|
|
||||||
static int
|
static int
|
||||||
maildir_list_recurse( maildir_store_t *ctx, int isBox, int flags, int depth,
|
maildir_list_recurse( maildir_store_t *ctx, int isBox, int flags,
|
||||||
const char *inbox, uint inboxLen, const char *basePath, uint basePathLen,
|
const char *inbox, uint inboxLen, const char *basePath, uint basePathLen,
|
||||||
char *path, int pathLen, char *name, int nameLen )
|
char *path, int pathLen, char *name, int nameLen )
|
||||||
{
|
{
|
||||||
|
@ -389,7 +389,7 @@ maildir_list_recurse( maildir_store_t *ctx, int isBox, int flags, int depth,
|
||||||
closedir( dir );
|
closedir( dir );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (++depth > 10) {
|
if (isBox > 10) {
|
||||||
// We do the other checks first to avoid confusing error messages for files.
|
// We do the other checks first to avoid confusing error messages for files.
|
||||||
error( "Maildir error: path %s is too deeply nested. Symlink loop?\n", path );
|
error( "Maildir error: path %s is too deeply nested. Symlink loop?\n", path );
|
||||||
closedir( dir );
|
closedir( dir );
|
||||||
|
@ -442,7 +442,7 @@ maildir_list_recurse( maildir_store_t *ctx, int isBox, int flags, int depth,
|
||||||
add_string_list( &ctx->boxes, name );
|
add_string_list( &ctx->boxes, name );
|
||||||
path[pl] = 0;
|
path[pl] = 0;
|
||||||
name[nl++] = '/';
|
name[nl++] = '/';
|
||||||
if (maildir_list_recurse( ctx, isBox + 1, flags, depth, inbox, inboxLen, basePath, basePathLen, path, pl, name, nl ) < 0) {
|
if (maildir_list_recurse( ctx, isBox + 1, flags, inbox, inboxLen, basePath, basePathLen, path, pl, name, nl ) < 0) {
|
||||||
closedir( dir );
|
closedir( dir );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -463,7 +463,7 @@ maildir_list_inbox( maildir_store_t *ctx, int flags, const char *basePath )
|
||||||
|
|
||||||
add_string_list( &ctx->boxes, "INBOX" );
|
add_string_list( &ctx->boxes, "INBOX" );
|
||||||
return maildir_list_recurse(
|
return maildir_list_recurse(
|
||||||
ctx, 1, flags, 0, NULL, 0, basePath, basePath ? strlen( basePath ) - 1 : 0,
|
ctx, 1, flags, NULL, 0, basePath, basePath ? strlen( basePath ) - 1 : 0,
|
||||||
path, nfsnprintf( path, _POSIX_PATH_MAX, "%s/", ctx->conf->inbox ),
|
path, nfsnprintf( path, _POSIX_PATH_MAX, "%s/", ctx->conf->inbox ),
|
||||||
name, nfsnprintf( name, _POSIX_PATH_MAX, "INBOX/" ) );
|
name, nfsnprintf( name, _POSIX_PATH_MAX, "INBOX/" ) );
|
||||||
}
|
}
|
||||||
|
@ -480,7 +480,7 @@ maildir_list_path( maildir_store_t *ctx, int flags, const char *inbox )
|
||||||
if (maildir_ensure_path( ctx->conf ) < 0)
|
if (maildir_ensure_path( ctx->conf ) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
return maildir_list_recurse(
|
return maildir_list_recurse(
|
||||||
ctx, 0, flags, 0, inbox, inbox ? strlen( inbox ) : 0, NULL, 0,
|
ctx, 0, flags, inbox, inbox ? strlen( inbox ) : 0, NULL, 0,
|
||||||
path, nfsnprintf( path, _POSIX_PATH_MAX, "%s", ctx->conf->path ),
|
path, nfsnprintf( path, _POSIX_PATH_MAX, "%s", ctx->conf->path ),
|
||||||
name, 0 );
|
name, 0 );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user