Skip to content

Commit

Permalink
Fix an off-by-one when setting the first bit exceeding the current bi…
Browse files Browse the repository at this point in the history
…tmap size

When setting bit n (the n+1th bit) of an n-bit vbitmap, we'd miss to
expand the bitmap and thus overflow our buffer and overwrite the first
bit of the next byte in memory.
  • Loading branch information
nigoroll committed Mar 3, 2016
1 parent 7bddf5a commit 5ca41d8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/vbm.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ vbit_set(struct vbitmap *vb, unsigned bit)
{

if (bit >= vb->nbits)
vbit_expand(vb, bit);
vbit_expand(vb, bit + 1);
vb->bits[VBITMAP_IDX(bit)] |= VBITMAP_BIT(bit);
}

Expand Down

0 comments on commit 5ca41d8

Please sign in to comment.