Skip to content

Commit

Permalink
guard the vidpid
Browse files Browse the repository at this point in the history
and cleanup the offset error output
  • Loading branch information
dexter93 committed May 31, 2023
1 parent 6bff510 commit 782a083
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sonixflasher.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@ int main(int argc, char* argv[])
vid = wordbuf[0]; pid = wordbuf[1];
}
}
// make sure we have the correct vidpid
if(vid == 0 || pid == 0) {
fprintf(stderr, "ERROR: invalid vidpid -'%s'.\n",optarg);
exit(1);
}
break;
case 'f': // file name
file_name = optarg;
Expand All @@ -299,7 +304,7 @@ int main(int argc, char* argv[])
char *endptr;
offset = strtol(optarg, &endptr, 0);
if (errno == ERANGE || *endptr != '\0') {
fprintf(stderr, "ERROR: invalid offset value '-%c'.\n", optopt);
fprintf(stderr, "ERROR: invalid offset value -'%s'.\n", optarg);
exit(1);
}
break;
Expand Down

0 comments on commit 782a083

Please sign in to comment.