From 9136aabe2adc143a9ceff69bf5449bf87976dce6 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 31 May 2008 17:48:00 +0200 Subject: [PATCH] Remove trailing slashes from base-dir arg. --- adu.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/adu.c b/adu.c index ae8cc43..deb3e94 100644 --- a/adu.c +++ b/adu.c @@ -1041,11 +1041,22 @@ static int check_args(void) { int i, ret; + /* remove trailing slashes from base-dir arg */ + if (conf.base_dir_given) { + size_t len = strlen(conf.base_dir_arg); + for (;;) { + if (!len) /* empty string */ + return -ERRNO_TO_ERROR(EINVAL); + if (!--len) /* length 1 is always OK */ + break; + if (conf.base_dir_arg[len] != '/') + break; /* no trailing slash, also OK */ + conf.base_dir_arg[len] = '\0'; + } + } if (!conf.uid_given) return 0; - admissible_uids = para_malloc(conf.uid_given * sizeof(*admissible_uids)); - for (i = 0; i < conf.uid_given; i++) { ret = parse_uid_range(conf.uid_arg[i], admissible_uids + i); if (ret < 0) -- 2.39.5