forked from Imagelibrary/rtems
libfs/rfs: Check search bit map end on last bit
- Do not write past the last location of the search bit map whe nit is being created. Closes #4148
This commit is contained in:
@@ -34,6 +34,12 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <rtems/rfs/rtems-rfs-bitmaps.h>
|
#include <rtems/rfs/rtems-rfs-bitmaps.h>
|
||||||
|
|
||||||
|
#define rtems_rfs_bitmap_check(_c, _sm) \
|
||||||
|
_Assert(_sm >= _c->search_bits && \
|
||||||
|
_sm < (_c->search_bits + \
|
||||||
|
rtems_rfs_bitmap_elements(rtems_rfs_bitmap_elements(_c->size))))
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test a bit in an element. If set return true else return false.
|
* Test a bit in an element. If set return true else return false.
|
||||||
*
|
*
|
||||||
@@ -220,6 +226,7 @@ rtems_rfs_bitmap_map_set (rtems_rfs_bitmap_control* control,
|
|||||||
index = rtems_rfs_bitmap_map_index (bit);
|
index = rtems_rfs_bitmap_map_index (bit);
|
||||||
offset = rtems_rfs_bitmap_map_offset (bit);
|
offset = rtems_rfs_bitmap_map_offset (bit);
|
||||||
search_map[index] = rtems_rfs_bitmap_set (search_map[index], 1 << offset);
|
search_map[index] = rtems_rfs_bitmap_set (search_map[index], 1 << offset);
|
||||||
|
rtems_rfs_bitmap_check(control, &search_map[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -260,6 +267,7 @@ rtems_rfs_bitmap_map_clear (rtems_rfs_bitmap_control* control,
|
|||||||
index = rtems_rfs_bitmap_map_index (bit);
|
index = rtems_rfs_bitmap_map_index (bit);
|
||||||
offset = rtems_rfs_bitmap_map_offset(bit);
|
offset = rtems_rfs_bitmap_map_offset(bit);
|
||||||
search_map[index] = rtems_rfs_bitmap_clear (search_map[index], 1 << offset);
|
search_map[index] = rtems_rfs_bitmap_clear (search_map[index], 1 << offset);
|
||||||
|
rtems_rfs_bitmap_check(control, &search_map[index]);
|
||||||
rtems_rfs_buffer_mark_dirty (control->buffer);
|
rtems_rfs_buffer_mark_dirty (control->buffer);
|
||||||
control->free++;
|
control->free++;
|
||||||
|
|
||||||
@@ -599,6 +607,7 @@ rtems_rfs_bitmap_create_search (rtems_rfs_bitmap_control* control)
|
|||||||
size = control->size;
|
size = control->size;
|
||||||
bit = 0;
|
bit = 0;
|
||||||
|
|
||||||
|
rtems_rfs_bitmap_check(control, search_map);
|
||||||
*search_map = RTEMS_RFS_BITMAP_ELEMENT_CLEAR;
|
*search_map = RTEMS_RFS_BITMAP_ELEMENT_CLEAR;
|
||||||
while (size)
|
while (size)
|
||||||
{
|
{
|
||||||
@@ -633,9 +642,13 @@ rtems_rfs_bitmap_create_search (rtems_rfs_bitmap_control* control)
|
|||||||
if (bit == (rtems_rfs_bitmap_element_bits () - 1))
|
if (bit == (rtems_rfs_bitmap_element_bits () - 1))
|
||||||
{
|
{
|
||||||
bit = 0;
|
bit = 0;
|
||||||
|
if (size > 0)
|
||||||
|
{
|
||||||
search_map++;
|
search_map++;
|
||||||
|
rtems_rfs_bitmap_check(control, search_map);
|
||||||
*search_map = RTEMS_RFS_BITMAP_ELEMENT_CLEAR;
|
*search_map = RTEMS_RFS_BITMAP_ELEMENT_CLEAR;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
bit++;
|
bit++;
|
||||||
map++;
|
map++;
|
||||||
|
|||||||
Reference in New Issue
Block a user