From b6f0a18e4128aee1b4213faa0d2d655083016b49 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 5 Sep 2004 08:29:30 +0000 Subject: [PATCH] Don't try to allocate file that's too big in filehdr_allocate. --- src/filesys/filehdr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/filesys/filehdr.c b/src/filesys/filehdr.c index 1f35946..d7d2cc2 100644 --- a/src/filesys/filehdr.c +++ b/src/filesys/filehdr.c @@ -22,12 +22,15 @@ filehdr_allocate (struct bitmap *b, off_t length) ASSERT (b != NULL); ASSERT (length >= 0); + sector_cnt = (length / DISK_SECTOR_SIZE) + (length % DISK_SECTOR_SIZE > 0); + if (sector_cnt > DIRECT_CNT) + return false; + h = calloc (1, sizeof *h); if (h == NULL) return NULL; h->length = length; - sector_cnt = (length / DISK_SECTOR_SIZE) + (length % DISK_SECTOR_SIZE > 0); while (h->sector_cnt < sector_cnt) { size_t sector = bitmap_find_and_set (b); -- 2.30.2