4.104.114.84.95
Last change
on this file since 2d733c42 was
2d733c42,
checked in by Joel Sherrill <joel.sherrill@…>, on 01/20/99 at 15:48:22
|
More general fix based on bug report and patch from Ian Lance Taylor
<ian@…> to fix this problem:
There is a small bug in rtems_close in c/src/lib/libc/libio.c. It
does not check whether the file descriptor it is passed is open. This
can cause it to make a null dereference if it is passed a file
descriptor which is in the valid range but which was not opened, or
which was already closed.
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | /* |
---|
2 | * ioctl() system call |
---|
3 | * |
---|
4 | * This routine is not defined in the POSIX 1003.1b standard but is |
---|
5 | * commonly supported on most UNIX and POSIX systems. |
---|
6 | * |
---|
7 | * COPYRIGHT (c) 1989-1998. |
---|
8 | * On-Line Applications Research Corporation (OAR). |
---|
9 | * Copyright assigned to U.S. Government, 1994. |
---|
10 | * |
---|
11 | * The license and distribution terms for this file may be |
---|
12 | * found in the file LICENSE in this distribution or at |
---|
13 | * http://www.OARcorp.com/rtems/license.html. |
---|
14 | * |
---|
15 | * $Id$ |
---|
16 | */ |
---|
17 | |
---|
18 | #include "libio_.h" |
---|
19 | |
---|
20 | int ioctl( |
---|
21 | int fd, |
---|
22 | unsigned32 command, |
---|
23 | void * buffer |
---|
24 | ) |
---|
25 | { |
---|
26 | rtems_status_code rc; |
---|
27 | rtems_libio_t *iop; |
---|
28 | |
---|
29 | rtems_libio_check_fd( fd ); |
---|
30 | iop = rtems_libio_iop( fd ); |
---|
31 | rtems_libio_check_is_open(iop); |
---|
32 | |
---|
33 | /* |
---|
34 | * If this file descriptor is mapped to an external set of handlers, |
---|
35 | * then pass the request on to them. |
---|
36 | */ |
---|
37 | |
---|
38 | if ( iop->flags & LIBIO_FLAGS_HANDLER_MASK ) { |
---|
39 | rtems_libio_ioctl_t fp; |
---|
40 | |
---|
41 | fp = rtems_libio_handlers[ |
---|
42 | (iop->flags >> LIBIO_FLAGS_HANDLER_SHIFT) - 1].ioctl; |
---|
43 | if ( fp == NULL ) |
---|
44 | set_errno_and_return_minus_one( EBADF ); |
---|
45 | |
---|
46 | return (*fp)( fd, command, buffer ); |
---|
47 | } |
---|
48 | |
---|
49 | /* |
---|
50 | * Now process the ioctl(). |
---|
51 | */ |
---|
52 | |
---|
53 | if ( !iop->handlers->ioctl ) |
---|
54 | set_errno_and_return_minus_one( ENOTSUP ); |
---|
55 | |
---|
56 | rc = (*iop->handlers->ioctl)( iop, command, buffer ); |
---|
57 | |
---|
58 | return rc; |
---|
59 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.