better validate arguments passed

This commit is contained in:
Jeremiah Orians 2021-10-04 20:49:44 -04:00
parent ae9e700592
commit ffe4e5f66e
No known key found for this signature in database
GPG Key ID: 6B3A3F198708F894
3 changed files with 26 additions and 8 deletions

20
cc.c
View File

@ -49,6 +49,7 @@ int main(int argc, char** argv)
init_macro_env("__M2__", "42", "__INTERNAL_M2__", 0); /* Setup __M2__ */
char* arch;
char* name;
char* hold;
int env=0;
char* val;
@ -68,6 +69,12 @@ int main(int argc, char** argv)
}
name = argv[i + 1];
if(NULL == name)
{
fputs("did not receive a file name\n", stderr);
exit(EXIT_FAILURE);
}
in = fopen(name, "r");
if(NULL == in)
{
@ -113,7 +120,13 @@ int main(int argc, char** argv)
}
else if(match(argv[i], "--max-string"))
{
MAX_STRING = strtoint(argv[i+1]);
hold = argv[i+1];
if(NULL == hold)
{
fputs("--max-string requires a numeric argument\n", stderr);
exit(EXIT_FAILURE);
}
MAX_STRING = strtoint(hold);
require(0 < MAX_STRING, "Not a valid string size\nAbort and fix your --max-string\n");
i = i + 2;
}
@ -140,6 +153,11 @@ int main(int argc, char** argv)
else if(match(argv[i], "-D"))
{
val = argv[i+1];
if(NULL == val)
{
fputs("-D requires an argument", stderr);
exit(EXIT_FAILURE);
}
while(0 != val[0])
{
if('=' == val[0])

View File

@ -212,9 +212,9 @@ eb1f6aab09a1a4966f9f49a518d8aa03ca97aa7c46e443871d758a306671a85e test/results/t
a2cbfd5f76d3be8049c6737e3fa02f191caf29b6885db006fa23f86e6eacc186 test/results/test0106-knight-posix-binary
5d25eda44320f9ff2869d9ee5bc0808b4ffd13c8803fb922c3c6759cfa39be32 test/results/test0106-riscv64-binary
473cc504d6cba9eaf648abcf15c83a317ff3f4a7f08f5e8936e3b35b2cc4fbc6 test/results/test0106-x86-binary
b79acd0d41ea9856c5277e06049366f87445f4d51a307aa27292133ea5e735a4 test/results/test1000-aarch64-binary
c5c89c50b468a3503f6769157caf527476803ada5483567cc339cfa38e3e11d5 test/results/test1000-amd64-binary
e06d27eb83135b88cdf223152b597ad334e6e6c033d3f1f2326b10ef4688454d test/results/test1000-armv7l-binary
ad8072abe909763482ecbd4cec8558e0a2a988632cc62564cc113115a8a0cd43 test/results/test1000-knight-posix-binary
704b4db57397f456d4cba3ec23cb198084f5e936b42033051f46633e00ec28fa test/results/test1000-riscv64-binary
d7baea4fa71a8f11980dd09e1d89df7cd7a7d5d872394461a5b2631f579ea2f7 test/results/test1000-x86-binary
af40eec9f8fedb23d073696a02e11e04bb5446ed97bcbd0b79bf9101fa4d7b23 test/results/test1000-aarch64-binary
6d6186142d7277b81442bfa92f2ca1954a65c301470031dd92570ced92b1f294 test/results/test1000-amd64-binary
e3749d1d25de39147008ca6c439dc6b8e426f05b7a0a39eb3a12b9f224f30042 test/results/test1000-armv7l-binary
5b1bf70269464323c50db4003a525b412498f2ab37ff9cf7d9753f1213012ac5 test/results/test1000-knight-posix-binary
1d0d78b1714b900bc27b72b4aa6b9dcb3330188b9e44fa61ede9d57cac166e9e test/results/test1000-riscv64-binary
3ef12a7978ba55bc922316bdc31d1f15962ee954f31967ac8080e59bcafaf7f1 test/results/test1000-x86-binary

View File

@ -1 +1 @@
b2374c61032314f1575185630b864c2c10a46fa391d3c917ebaa6c060b2269ea test/test1000/proof
dad8b8bddecc2a7b9e23c387daf3e74e7268da415c56cecbaef1f4bae23aed20 test/test1000/proof