Changeset f0fe043 in rtems-libbsd


Ignore:
Timestamp:
09/19/23 21:02:47 (3 months ago)
Author:
Kinsey Moore <kinsey.moore@…>
Branches:
6-freebsd-12
Children:
1524f95
Parents:
7cc487f
git-author:
Kinsey Moore <kinsey.moore@…> (09/19/23 21:02:47)
git-committer:
Joel Sherrill <joel@…> (09/20/23 20:50:25)
Message:

rtemsbsd/libio: Handle invalid descriptors

The documentation for this function suggests that it can handle invalid
descriptors safely. This change allows negative descriptors to be
handled without a crash.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rtemsbsd/include/machine/rtems-bsd-libio.h

    r7cc487f rf0fe043  
    229229        unsigned int flags = 0;
    230230        int ffd = -1;
    231         if (fd < rtems_libio_number_iops) {
     231        if (fd >= 0 && fd < rtems_libio_number_iops) {
    232232                iop = rtems_libio_iop(fd);
    233233                flags = rtems_libio_iop_hold(iop);
     
    250250                        flags = iop->flags;
    251251        } else {
    252                 *iopp = NULL;
     252                if (iopp != NULL) {
     253                        *iopp = NULL;
     254                }
    253255        }
    254256        if (RTEMS_BSD_DESCRIP_TRACE)
Note: See TracChangeset for help on using the changeset viewer.