aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2019-11-08 14:01:58 +0100
committerMitch Bradley <wmb@firmworks.com>2019-11-08 07:30:53 -1000
commit7e2bc18ea8e7894b5742e7aaad7b8374a8f6f7ff (patch)
tree3383cf86165ee94b5887e6a9a60712cc6ceb0bd7
parent31df9cb7d88cc31f39e2f9cf637e7c43036a3175 (diff)
downloadcforth-7e2bc18ea8e7894b5742e7aaad7b8374a8f6f7ff.tar.gz
makebi: add some sanity checks
Make sure the input file was exactly the size we'd expect it to be.
-rwxr-xr-xsrc/cforth/embed/makebi.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/cforth/embed/makebi.c b/src/cforth/embed/makebi.c
index 0d853a2..521e63b 100755
--- a/src/cforth/embed/makebi.c
+++ b/src/cforth/embed/makebi.c
@@ -57,6 +57,10 @@ void bytes_to_file(char *filename, FILE *infile, int len)
}
for (i = 0; i < len; i++) {
c = fgetc(infile);
+ if (c == EOF) {
+ fprintf(stderr, "Short read from %s\n", filename);
+ exit(1);
+ }
fprintf(outfile, "0x%02x, ", c);
if ((i&7) == 7) {
fputc('\n', outfile);
@@ -91,6 +95,11 @@ int main(argc, argv)
bytes_to_file("dict.h", infile, dictsize);
bytes_to_file("userarea.h", infile, uasize);
+ if (fgetc(infile) != EOF) {
+ fprintf(stderr, "Extra data in the input file %s\n", dictionary_file);
+ exit(1);
+ }
+
fclose(infile);
return 0;
}