1
0
mirror of https://github.com/UzixLS/picocom.git synced 2025-07-19 07:21:18 +03:00

Barf if superfluous non-opt arguments are present

Fixes issue #52
This commit is contained in:
Nick Patavalis
2016-12-07 00:37:04 +02:00
parent 71e36b0f83
commit 18468a15a8

View File

@ -1503,9 +1503,17 @@ parse_args(int argc, char *argv[])
fprintf(stderr, "Run with '--help'.\n");
exit(EXIT_FAILURE);
}
strncpy(opts.port, argv[optind], sizeof(opts.port) - 1);
strncpy(opts.port, argv[optind++], sizeof(opts.port) - 1);
opts.port[sizeof(opts.port) - 1] = '\0';
if ( argc != optind ) {
fprintf(stderr, "Unexpected non-option arguments: ");
while (argc != optind)
fprintf(stderr, "%s ", argv[optind++]);
fprintf(stderr, "\n");
exit(EXIT_FAILURE);
}
#ifndef NO_HELP
printf("picocom v%s\n", VERSION_STR);
printf("\n");