From: Andre Noll Date: Sat, 31 May 2008 15:48:00 +0000 (+0200) Subject: Remove trailing slashes from base-dir arg. X-Git-Tag: v0.0.2~32 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=9136aabe2adc143a9ceff69bf5449bf87976dce6;p=adu.git Remove trailing slashes from base-dir arg. --- 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)