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 ae8cc43..deb3e94 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)