Skip to content

Commit

Permalink
driver: Fix crashes on missing cli arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
povik committed Feb 12, 2024
1 parent 2098967 commit ecb62f3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion kernel/driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,15 @@ int getopt(int argc, char **argv, const char *optstring)
return optopt;
}

optarg = argv[++optind];
if (++optind >= argc) {
fprintf(stderr, "%s: option '-%c' expects an argument\n", argv[0], optopt);
optopt = '?';
return optopt;
}

optarg = argv[optind];
optind++, optcur = 1;

return optopt;
}

Expand Down

0 comments on commit ecb62f3

Please sign in to comment.