]> git.tue.mpg.de Git - adu.git/commitdiff
Remove trailing slashes from base-dir arg.
authorAndre Noll <maan@systemlinux.org>
Sat, 31 May 2008 15:48:00 +0000 (17:48 +0200)
committerAndre Noll <maan@systemlinux.org>
Sat, 31 May 2008 15:48:00 +0000 (17:48 +0200)
adu.c

diff --git a/adu.c b/adu.c
index ae8cc43efd73109c3a6b70591beecea45ec2b99b..deb3e94ccd88bf309263b57a87e307de9e00944c 100644 (file)
--- 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)