This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: No checking of index while accessing file descriptor table might lead to a crash
- From: "Gary Thomas" <gary at mlbassoc dot com>
- To: sebastien dot couret at elios-informatique dot fr
- Cc: ecos-discuss at ecos dot sourceware dot org
- Date: Wed, 10 Mar 2004 05:42:29 -0700 (MST)
- Subject: Re: [ECOS] No checking of index while accessing file descriptor table might lead to a crash
- References: <MELELIOS5BzC533iJ0h00000496@melelios.dmz.elios-informatique.fr>
sebastien Couret said:
> Hello All,
>
> I was playing around trying to write down an 'lsof' style application for
> eCOS but my application was crashing again and again.
>
> I finally come into the file
> [ECOS_REPOSITORY]/io/fileio/current/src/fd.cxx
> to see that file descriptors are stored in a table named desc of size
> CYGNUM_FILEIO_NFD.
>
> What surprised me in that the file descriptor index is not checked while
> accessing to this table (a.k.a check 0<fd<CYGNUM_FILEIO_NFD)
>
> As a result,I think this functions will probably crash, if u pass an fd
>>=CYGNUM_FILEIO_NFD to them.
>
> fd_close
> cyg_fd_assign
> cyg_fd_free
> cyg_fp_get
>
>
> It might be usefull to add an "assert(0<fd<CYGNUM_FILEIO_NFD);" at the
> beginning of the previous functions.
>
> What do U think of it ?
Sounds reasonable. Why not provide us with a patch that does just that?
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss