From 48f371d380e07ba29b1ed7fce09ae4906eef4e78 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Mon, 8 Jun 2020 06:47:06 -0400 Subject: [PATCH] emul: add sanity check for blkfs --- emul/emul.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/emul/emul.c b/emul/emul.c index 4c82643..6075125 100644 --- a/emul/emul.c +++ b/emul/emul.c @@ -86,6 +86,13 @@ Machine* emul_init() fprintf(stderr, "Can't open\n"); return NULL; } + fseek(blkfp, 0, SEEK_END); + if (ftell(blkfp) < 100 * 1024) { + fclose(blkfp); + fprintf(stderr, "emul/blkfs too small, something's wrong, aborting.\n"); + return NULL; + } + fseek(blkfp, 0, SEEK_SET); // initialize memory memset(m.mem, 0, 0x10000); FILE *bfp = fopen(FBIN_PATH, "r");