Changeset d5fc2a6a in rtems


Ignore:
Timestamp:
May 5, 2020, 4:55:34 AM (6 months ago)
Author:
Chris Johns <chrisj@…>
Branches:
5, master
Children:
3635d6a
Parents:
b77670fd
Message:

libdl/obj-cache: Fail if the read offset is past the file length

  • The check was for greater than and not equal or greater

Updates #3969

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libdl/rtl-obj-cache.c

    rb77670fd rd5fc2a6a  
    8181
    8282  if (rtems_rtl_trace (RTEMS_RTL_TRACE_CACHE))
    83     printf ("rtl: cache: %2d: fd=%d offset=%" PRIdoff_t "length=%zu area=[%"
     83    printf ("rtl: cache: %2d: fd=%d offset=%" PRIdoff_t " length=%zu area=[%"
    8484            PRIdoff_t ",%" PRIdoff_t "] cache=[%" PRIdoff_t ",%" PRIdoff_t "] size=%zu\n",
    8585            fd, cache->fd, offset, *length,
     
    9696  if (cache->fd == fd)
    9797  {
    98     if (offset > cache->file_size)
     98    if (offset >= cache->file_size)
    9999    {
    100100      rtems_rtl_set_error (EINVAL, "offset past end of file: offset=%i size=%i",
     
    111111      if (rtems_rtl_trace (RTEMS_RTL_TRACE_CACHE))
    112112        printf ("rtl: cache: %2d: truncate length=%d\n", fd, (int) *length);
     113
    113114    }
    114115  }
     
    176177
    177178    if (rtems_rtl_trace (RTEMS_RTL_TRACE_CACHE))
    178       printf ("rtl: cache: %2d: seek: offset=%" PRIdoff_t "buffer_offset=%zu"
    179               "read=%zu cache=[%" PRIdoff_t ",%" PRIdoff_t "] "
     179      printf ("rtl: cache: %2d: seek: offset=%" PRIdoff_t " buffer_offset=%zu"
     180              " read=%zu cache=[%" PRIdoff_t ",%" PRIdoff_t "] "
    180181              "dist=%" PRIdoff_t "\n",
    181182              fd, offset + buffer_offset, buffer_offset, buffer_read,
Note: See TracChangeset for help on using the changeset viewer.