Starting to restrict bad input
This commit is contained in:
parent
6341302101
commit
923784c797
26
cc_reader.c
26
cc_reader.c
|
@ -22,6 +22,18 @@ int line;
|
|||
char* file;
|
||||
int in_set(int c, char* s);
|
||||
|
||||
|
||||
/* Deal with common errors */
|
||||
void require(int bool, char* error)
|
||||
{
|
||||
if(!bool)
|
||||
{
|
||||
file_print(error, stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int clearWhiteSpace(int c)
|
||||
{
|
||||
if((32 == c) || (9 == c)) return clearWhiteSpace(fgetc(input));
|
||||
|
@ -37,6 +49,7 @@ int consume_byte(int c)
|
|||
{
|
||||
hold_string[string_index] = c;
|
||||
string_index = string_index + 1;
|
||||
require(MAX_STRING > string_index, "Token exceeded 4096char limit\n");
|
||||
return fgetc(input);
|
||||
}
|
||||
|
||||
|
@ -49,6 +62,7 @@ int preserve_string(int c)
|
|||
if(!escape && '\\' == c ) escape = TRUE;
|
||||
else escape = FALSE;
|
||||
c = consume_byte(c);
|
||||
require(EOF != c, "Unterminated string\n");
|
||||
} while(escape || (c != frequent));
|
||||
return fgetc(input);
|
||||
}
|
||||
|
@ -78,7 +92,11 @@ int preserve_keyword(int c, char* S)
|
|||
|
||||
int purge_macro(int ch)
|
||||
{
|
||||
while(10 != ch) ch = fgetc(input);
|
||||
while(10 != ch)
|
||||
{
|
||||
ch = fgetc(input);
|
||||
require(EOF != ch, "Hit EOF inside macro\n");
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
|
||||
|
@ -139,10 +157,12 @@ reset:
|
|||
while(c != '*')
|
||||
{
|
||||
c = fgetc(input);
|
||||
if(10 == c) line = line + 1;
|
||||
require(EOF != c, "Hit EOF inside of block comment\n");
|
||||
if('\n' == c) line = line + 1;
|
||||
}
|
||||
c = fgetc(input);
|
||||
if(10 == c) line = line + 1;
|
||||
require(EOF != c, "Hit EOF inside of block comment\n");
|
||||
if('\n' == c) line = line + 1;
|
||||
}
|
||||
c = fgetc(input);
|
||||
goto reset;
|
||||
|
|
|
@ -53,10 +53,10 @@ a0ae067746e7a2b01d33950da1cf640e12c3a70a045ab331ea2025af59dec9af test/results/t
|
|||
1154f39f25dcd6d914e9a542306f95280926baf985d011b2152c7ea0b87ab42d test/results/test10-knight-native-binary
|
||||
c1b5a2a3cd46c5e95e5540e871c2a916e028684ca80f51c001ef489342e27625 test/results/test10-knight-posix-binary
|
||||
b3e13d54aab689137628fb9c4487bfd8288f9bd18bef8fe756577c8d2dce1f1f test/results/test10-x86-binary
|
||||
ff1e505973de0320da9122c8ae791be44d96fa968de3a2262b8107528061a881 test/results/test100-amd64-binary
|
||||
7e065fc378341f617a3736d7e64aa397eded3afa79b2328458b7722db33580b8 test/results/test100-armv7l-binary
|
||||
d32ec31c7a4a1f68283a0deff47446d95bbb218cc27b13ca83bae2f03c0d4787 test/results/test100-knight-posix-binary
|
||||
cfefaccf2e8a625d2aff45c096067bed8f6ae8f6128ffc85d13c91f74e3892da test/results/test100-x86-binary
|
||||
c0becbe4e1edb7218bf2f6849493f768da8078a87af18ff093eaf9f6c1fcb9e7 test/results/test100-amd64-binary
|
||||
d95bd6ad6a59ef9f508e462ebb4b716f2799ed30a5882c549156cb0f3ca00a42 test/results/test100-armv7l-binary
|
||||
d044e557477b6a2db1c983d353bc7aa2080600894839947f5191ee524f231300 test/results/test100-knight-posix-binary
|
||||
8e33e2bf5cdb0c127cca0c4bdbc627d7f2cbdb5130aadedbfc01a379520174a0 test/results/test100-x86-binary
|
||||
34e6d535e30ef8826a4ad1a4d08b76cfa370c54595599ad3be784b64c9cd8ec5 test/results/test11-amd64-binary
|
||||
893695e6f300a0fe055fad935a56abd549bba70d1d39c535a680f41bbb73f117 test/results/test11-armv7l-binary
|
||||
955b564d2c89abf2cfc6c80d766cd11479d146b828dec69e654b0958a62d5e6e test/results/test11-knight-native-binary
|
||||
|
|
|
@ -1 +1 @@
|
|||
a4a464f5172da526b6dcfcb806341078c0c89c68fdeff2709d8625a7800b1530 test/test100/proof
|
||||
cdfe50b2c9eac325f228fce9146358df4ef672f030cf936506a445555716cf89 test/test100/proof
|
||||
|
|
Loading…
Reference in New Issue