ssb_sprom: Fix segfault in parameter parsing code.
authorMichael Buesch <mb@bu3sch.de>
Mon, 16 Jun 2008 16:30:12 +0000 (18:30 +0200)
committerMichael Buesch <mb@bu3sch.de>
Mon, 16 Jun 2008 16:30:12 +0000 (18:30 +0200)
Signed-off-by: Michael Buesch <mb@bu3sch.de>
ssb_sprom/ssb_sprom.c

index facacab9f643f0ca9762908f79ce2f0f9610e9c4..a9080a20482556e4284a36b89345d907814af0eb 100644 (file)
@@ -1016,12 +1016,12 @@ static int do_cmp_arg(char **argv, int *pos,
        }
        if (strcmp(arg, template) == 0) {
                if (param) {
-                       /* Skip the parameter on the next iteration. */
-                       (*pos)++;
                        if (*param == 0) {
                                prerror("%s needs a parameter\n", arg);
                                return ARG_ERROR;
                        }
+                       /* Skip the parameter on the next iteration. */
+                       (*pos)++;
                }
                return ARG_MATCH;
        }
@@ -1511,7 +1511,8 @@ static int parse_args(int argc, char *argv[])
                        if (err)
                                goto error;
                } else {
-                       prerror("Unrecognized argument: %s\n", argv[i]);
+                       if (!parse_err)
+                               prerror("Unrecognized argument: %s\n", argv[i]);
                        goto out_usage;
                }
                if (parse_err)