Changeset 7021c014 in rtems


Ignore:
Timestamp:
Oct 15, 2020, 6:14:22 AM (6 weeks ago)
Author:
Chris Johns <chrisj@…>
Branches:
5
Children:
f84c4a5
Parents:
e71e271
git-author:
Chris Johns <chrisj@…> (10/15/20 06:14:22)
git-committer:
Chris Johns <chrisj@…> (10/16/20 23:55:30)
Message:

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 #4149

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libfs/src/rfs/rtems-rfs-bitmaps.c

    re71e271 r7021c014  
    3434#include <stdlib.h>
    3535#include <rtems/rfs/rtems-rfs-bitmaps.h>
     36
     37#define rtems_rfs_bitmap_check(_c, _sm) \
     38   _Assert(_sm >= _c->search_bits && \
     39           _sm < (_c->search_bits + \
     40             rtems_rfs_bitmap_elements(rtems_rfs_bitmap_elements(_c->size))))
     41
    3642
    3743/**
     
    221227    offset = rtems_rfs_bitmap_map_offset (bit);
    222228    search_map[index] = rtems_rfs_bitmap_set (search_map[index], 1 << offset);
     229    rtems_rfs_bitmap_check(control, &search_map[index]);
    223230  }
    224231
     
    261268  offset            = rtems_rfs_bitmap_map_offset(bit);
    262269  search_map[index] = rtems_rfs_bitmap_clear (search_map[index], 1 << offset);
     270  rtems_rfs_bitmap_check(control, &search_map[index]);
    263271  rtems_rfs_buffer_mark_dirty (control->buffer);
    264272  control->free++;
     
    600608  bit = 0;
    601609
     610  rtems_rfs_bitmap_check(control, search_map);
    602611  *search_map = RTEMS_RFS_BITMAP_ELEMENT_CLEAR;
    603612  while (size)
     
    634643    {
    635644      bit = 0;
    636       search_map++;
    637       *search_map = RTEMS_RFS_BITMAP_ELEMENT_CLEAR;
     645      if (size > 0)
     646      {
     647        search_map++;
     648        rtems_rfs_bitmap_check(control, search_map);
     649        *search_map = RTEMS_RFS_BITMAP_ELEMENT_CLEAR;
     650      }
    638651    }
    639652    else
Note: See TracChangeset for help on using the changeset viewer.