Skip to content

Commit

Permalink
Add extra validation
Browse files Browse the repository at this point in the history
  • Loading branch information
rockisch committed Oct 23, 2022
1 parent 9e0bb2c commit 0f7fc51
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
int main(int argc, char **argv) {
int FIXED_ARGS = 4;
if (argc < FIXED_ARGS) {
printf("\nusage: main.exe <charID> <isNewChar> <logintoken> [loginmessages...]");
printf("usage: main.exe <charID> <isNewChar> <logintoken> [loginmessages...]");
return 0;
}
uint32_t char_id = atoi(argv[1]);
uint8_t is_new = atoi(argv[2]) > 0;
char *logintoken = argv[3];
if (strlen(logintoken) != 16) {
fprintf(stderr, "error: logintoken must be 16 characters long");
return 0;
}

char **marr = malloc(8 * sizeof(char**));
int mlen = 0;
Expand All @@ -20,6 +24,7 @@ int main(int argc, char **argv) {
}
}

start(char_id, is_new, logintoken, marr, mlen);
uint32_t result = start(char_id, is_new, logintoken, marr, mlen);
printf("game closed with status %d", result);
free(marr);
}

0 comments on commit 0f7fc51

Please sign in to comment.