<div dir="ltr">Does this need to go on 4.11 as well? I can't imaging this code has changed.<div><br></div><div>May even be the same in 4.10.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 15, 2020 at 1:40 AM <<a href="mailto:chrisj@rtems.org">chrisj@rtems.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: Chris Johns <<a href="mailto:chrisj@rtems.org" target="_blank">chrisj@rtems.org</a>><br>
<br>
- Do not write past the last location of the search bit map<br>
whe nit is being created.<br>
<br>
Closes #4149<br>
---<br>
cpukit/libfs/src/rfs/rtems-rfs-bitmaps.c | 17 +++++++++++++++--<br>
1 file changed, 15 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/cpukit/libfs/src/rfs/rtems-rfs-bitmaps.c b/cpukit/libfs/src/rfs/rtems-rfs-bitmaps.c<br>
index 7973e85083..6da555d50e 100644<br>
--- a/cpukit/libfs/src/rfs/rtems-rfs-bitmaps.c<br>
+++ b/cpukit/libfs/src/rfs/rtems-rfs-bitmaps.c<br>
@@ -34,6 +34,12 @@<br>
#include <stdlib.h><br>
#include <rtems/rfs/rtems-rfs-bitmaps.h><br>
<br>
+#define rtems_rfs_bitmap_check(_c, _sm) \<br>
+ _Assert(_sm >= _c->search_bits && \<br>
+ _sm < (_c->search_bits + \<br>
+ rtems_rfs_bitmap_elements(rtems_rfs_bitmap_elements(_c->size))))<br>
+<br>
+<br>
/**<br>
* Test a bit in an element. If set return true else return false.<br>
*<br>
@@ -220,6 +226,7 @@ rtems_rfs_bitmap_map_set (rtems_rfs_bitmap_control* control,<br>
index = rtems_rfs_bitmap_map_index (bit);<br>
offset = rtems_rfs_bitmap_map_offset (bit);<br>
search_map[index] = rtems_rfs_bitmap_set (search_map[index], 1 << offset);<br>
+ rtems_rfs_bitmap_check(control, &search_map[index]);<br>
}<br>
<br>
return 0;<br>
@@ -260,6 +267,7 @@ rtems_rfs_bitmap_map_clear (rtems_rfs_bitmap_control* control,<br>
index = rtems_rfs_bitmap_map_index (bit);<br>
offset = rtems_rfs_bitmap_map_offset(bit);<br>
search_map[index] = rtems_rfs_bitmap_clear (search_map[index], 1 << offset);<br>
+ rtems_rfs_bitmap_check(control, &search_map[index]);<br>
rtems_rfs_buffer_mark_dirty (control->buffer);<br>
control->free++;<br>
<br>
@@ -599,6 +607,7 @@ rtems_rfs_bitmap_create_search (rtems_rfs_bitmap_control* control)<br>
size = control->size;<br>
bit = 0;<br>
<br>
+ rtems_rfs_bitmap_check(control, search_map);<br>
*search_map = RTEMS_RFS_BITMAP_ELEMENT_CLEAR;<br>
while (size)<br>
{<br>
@@ -633,8 +642,12 @@ rtems_rfs_bitmap_create_search (rtems_rfs_bitmap_control* control)<br>
if (bit == (rtems_rfs_bitmap_element_bits () - 1))<br>
{<br>
bit = 0;<br>
- search_map++;<br>
- *search_map = RTEMS_RFS_BITMAP_ELEMENT_CLEAR;<br>
+ if (size > 0)<br>
+ {<br>
+ search_map++;<br>
+ rtems_rfs_bitmap_check(control, search_map);<br>
+ *search_map = RTEMS_RFS_BITMAP_ELEMENT_CLEAR;<br>
+ }<br>
}<br>
else<br>
bit++;<br>
-- <br>
2.24.1<br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div>