Fix the uid parser.
authorAndre Noll <maan@systemlinux.org>
Sat, 31 May 2008 18:40:33 +0000 (20:40 +0200)
committerAndre Noll <maan@systemlinux.org>
Sat, 31 May 2008 18:40:33 +0000 (20:40 +0200)
Using e.g. --uid 42 caused parse_uid_range() to pass a NULL pointer
to check_uid_arg().

adu.c

diff --git a/adu.c b/adu.c
index 8721089..b7be069 100644 (file)
--- a/adu.c
+++ b/adu.c
@@ -80,10 +80,8 @@ static int parse_uid_range(const char *orig_arg, struct uid_range *ur)
        int ret;
        char *arg = para_strdup(orig_arg), *p = strchr(arg, '-');
 
-       if (!p || p == arg) {
-               if (p == arg) /* -42 */
-                       p++;
-               ret = check_uid_arg(p, &ur->high);
+       if (!p || p == arg) { /* -42 or 42 */
+               ret = check_uid_arg(p? p + 1 : arg, &ur->high);
                if (ret < 0)
                        goto out;
                ur->low = p? 0 : ur->high;