projects
/
pintos-anon
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
762a09b
)
Don't try to allocate file that's too big in filehdr_allocate.
author
Ben Pfaff
<blp@cs.stanford.edu>
Sun, 5 Sep 2004 08:29:30 +0000
(08:29 +0000)
committer
Ben Pfaff
<blp@cs.stanford.edu>
Sun, 5 Sep 2004 08:29:30 +0000
(08:29 +0000)
src/filesys/filehdr.c
patch
|
blob
|
history
diff --git
a/src/filesys/filehdr.c
b/src/filesys/filehdr.c
index 1f35946479070e15884f839dfd3c58cbb097c94f..d7d2cc2af52ba24cc31f21419dd606c28f6a0fec 100644
(file)
--- 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);