summaryrefslogtreecommitdiff
path: root/fs.c
diff options
context:
space:
mode:
authorNickolai Zeldovich <[email protected]>2011-06-24 05:26:57 -0400
committerNickolai Zeldovich <[email protected]>2011-06-24 05:26:57 -0400
commit96b7da5f03e8fd1722cb66ef3cb7fcc02d703860 (patch)
tree0724ca9796356f313a15febad33a9c016481ea45 /fs.c
parentf70ef994dce8f6948edec8c534ae21742141dd50 (diff)
downloadxv6-labs-96b7da5f03e8fd1722cb66ef3cb7fcc02d703860.tar.gz
xv6-labs-96b7da5f03e8fd1722cb66ef3cb7fcc02d703860.tar.bz2
xv6-labs-96b7da5f03e8fd1722cb66ef3cb7fcc02d703860.zip
do not run past the end of the disk!
[ cherry-picked de6075ff0978108daea1d658425bcb37663a98a0 ] Conflicts: fs.c
Diffstat (limited to 'fs.c')
-rw-r--r--fs.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs.c b/fs.c
index 15a4d35..7c6d904 100644
--- a/fs.c
+++ b/fs.c
@@ -61,7 +61,7 @@ balloc(uint dev)
readsb(dev, &sb);
for(b = 0; b < sb.size; b += BPB){
bp = bread(dev, BBLOCK(b, sb.ninodes));
- for(bi = 0; bi < BPB; bi++){
+ for(bi = 0; bi < BPB && bi < (sb.size - b); bi++){
m = 1 << (bi % 8);
if((bp->data[bi/8] & m) == 0){ // Is block free?
bp->data[bi/8] |= m; // Mark block in use on disk.