diff options
-rw-r--r-- | listamsb.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -19,6 +19,10 @@ #define MAX_LINENO 63999 +/* a program bigger than this can't possibly fit into memory, + even with cart-based AMSB2 and no DOS loaded. */ +#define MAX_PROGLEN 30000 + const char *self; char pipe_command[BUFSIZ + 1] = { "a8cat" }; @@ -77,7 +81,11 @@ int read_header(void) { proglen = read_word(); - /* TODO: sanity check proglen */ + if(proglen > MAX_PROGLEN) { + fprintf(stderr, "%s: program too big (%d bytes), won't fit in Atari memory\n", + self, proglen); + } + return proglen; } @@ -212,10 +220,12 @@ void parse_args(int argc, char **argv) { } if(optind >= argc) { + freopen(NULL, "rb", stdin); infile = stdin; } else { infile = fopen(argv[optind], "rb"); if(!infile) { + fprintf(stderr, "%s: ", self); perror(argv[optind]); exit(1); } |