Skip to content

Commit

Permalink
do not run past the end of the disk!
Browse files Browse the repository at this point in the history
[ cherry-picked de6075f ]

Conflicts:

	fs.c
  • Loading branch information
zeldovich committed Jun 24, 2011
1 parent f70ef99 commit 96b7da5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 96b7da5

Please sign in to comment.