Changeset 6abdef37 in mainline for uspace/app/mkext4/mkext4.c


Ignore:
Timestamp:
2018-12-11T14:02:08Z (5 years ago)
Author:
Maurizio Lombardi <mlombard@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c9c1ccd
Parents:
9c3038d
Message:

mkext4: fix infinite loop when passing an invalid argument.

Also adds the —help parameter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/mkext4/mkext4.c

    r9c3038d r6abdef37  
    6868        ++argv;
    6969
    70         while (*argv[0] == '-') {
     70        while (*argv && *argv[0] == '-') {
    7171                if (str_cmp(*argv, "--size") == 0) {
    7272                        --argc;
     
    8787                        --argc;
    8888                        ++argv;
     89                        continue;
    8990                }
    9091
     
    107108                        --argc;
    108109                        ++argv;
     110                        continue;
    109111                }
    110112
     
    122124                        --argc;
    123125                        ++argv;
     126                        continue;
     127                }
     128
     129                if (str_cmp(*argv, "--help") == 0) {
     130                        syntax_print();
     131                        return 0;
    124132                }
    125133
     
    128136                        ++argv;
    129137                        break;
     138                } else {
     139                        printf(NAME ": Invalid argument: %s\n", *argv);
     140                        syntax_print();
     141                        return 1;
    130142                }
    131143        }
Note: See TracChangeset for help on using the changeset viewer.