LibBSD | rtemsbsd/libio: Give a duplicated descriptor an identity of its own (!153)

Sang Woo Kim (@physwkim) gitlab at rtems.org
Thu Jul 30 12:14:11 UTC 2026




Sang Woo Kim commented on a discussion on rtemsbsd/rtems/rtems-bsd-syscall-api.c: https://gitlab.rtems.org/rtems/pkg/rtems-libbsd/-/merge_requests/153#note_155909

 > +	struct thread *td;
 > +	rtems_libio_t *oiop;
 > +	struct file *fp;
 > +	int nfd;
 > +	int error;
 > +
 > +	if (path != NULL) {
 > +		return rtems_bsd_error_to_status_and_errno(ENXIO);
 > +	}
 > +	td = rtems_bsd_get_curthread_or_null();
 > +	if (td == NULL) {
 > +		return rtems_bsd_error_to_status_and_errno(ENOMEM);
 > +	}
 > +	oiop = rtems_bsd_libio_loc_to_iop(&iop->pathinfo);
 > +	if (oiop == NULL || oiop == iop || oiop < rtems_libio_iops ||
 > +	    oiop >= &rtems_libio_iops[rtems_libio_number_iops]) {

Agreed — moved the range check into `rtems_bsd_libio_loc_to_iop()`, which now returns NULL when `node_access` does not point into the iop table. The dup path keeps only the NULL and self checks, and `rtems_bsd_sysgen_fstat()` picks up the same protection through its existing NULL check.

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/pkg/rtems-libbsd/-/merge_requests/153#note_155909
You're receiving this email because of your account on gitlab.rtems.org. Unsubscribe from this thread: https://gitlab.rtems.org/-/sent_notifications/4-8dyogzshfvl1v1vuk676byn53-k/unsubscribe | Manage all notifications: https://gitlab.rtems.org/-/profile/notifications | Help: https://gitlab.rtems.org/help


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20260730/70a3283e/attachment-0001.htm>


More information about the bugs mailing list