~ubuntu-branches/ubuntu/lucid/rdesktop/lucid-security

« back to all changes in this revision

Viewing changes to serial.c

  • Committer: Bazaar Package Importer
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2007-10-21 21:34:16 UTC
  • Revision ID: james.westby@ubuntu.com-20071021213416-vcd360i0higuj6n8
Tags: 1.5.0-3+cvs20071006
Fix segfault in XGetPointerMapping() thanks to Felix Domke
(closes: #445779).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- c-basic-offset: 8 -*-
2
2
   rdesktop: A Remote Desktop Protocol client.
3
3
 
4
 
   Copyright (C) Matthew Chapman 1999-2005
5
 
   
 
4
   Copyright (C) Matthew Chapman 1999-2007
 
5
 
6
6
   This program is free software; you can redistribute it and/or modify
7
7
   it under the terms of the GNU General Public License as published by
8
8
   the Free Software Foundation; either version 2 of the License, or
9
9
   (at your option) any later version.
10
 
   
 
10
 
11
11
   This program is distributed in the hope that it will be useful,
12
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
150
150
extern RDPDR_DEVICE g_rdpdr_device[];
151
151
 
152
152
static SERIAL_DEVICE *
153
 
get_serial_info(NTHANDLE handle)
 
153
get_serial_info(RD_NTHANDLE handle)
154
154
{
155
155
        int index;
156
156
 
162
162
        return NULL;
163
163
}
164
164
 
165
 
static BOOL
166
 
get_termios(SERIAL_DEVICE * pser_inf, NTHANDLE serial_fd)
 
165
static RD_BOOL
 
166
get_termios(SERIAL_DEVICE * pser_inf, RD_NTHANDLE serial_fd)
167
167
{
168
168
        speed_t speed;
169
169
        struct termios *ptermios;
316
316
}
317
317
 
318
318
static void
319
 
set_termios(SERIAL_DEVICE * pser_inf, NTHANDLE serial_fd)
 
319
set_termios(SERIAL_DEVICE * pser_inf, RD_NTHANDLE serial_fd)
320
320
{
321
321
        speed_t speed;
322
322
 
553
553
        return count;
554
554
}
555
555
 
556
 
static NTSTATUS
 
556
static RD_NTSTATUS
557
557
serial_create(uint32 device_id, uint32 access, uint32 share_mode, uint32 disposition,
558
 
              uint32 flags_and_attributes, char *filename, NTHANDLE * handle)
 
558
              uint32 flags_and_attributes, char *filename, RD_NTHANDLE * handle)
559
559
{
560
 
        NTHANDLE serial_fd;
 
560
        RD_NTHANDLE serial_fd;
561
561
        SERIAL_DEVICE *pser_inf;
562
562
        struct termios *ptermios;
563
563
 
568
568
        if (serial_fd == -1)
569
569
        {
570
570
                perror("open");
571
 
                return STATUS_ACCESS_DENIED;
 
571
                return RD_STATUS_ACCESS_DENIED;
572
572
        }
573
573
 
574
574
        if (!get_termios(pser_inf, serial_fd))
575
575
        {
576
576
                printf("INFO: SERIAL %s access denied\n", g_rdpdr_device[device_id].name);
577
577
                fflush(stdout);
578
 
                return STATUS_ACCESS_DENIED;
 
578
                return RD_STATUS_ACCESS_DENIED;
579
579
        }
580
580
 
581
581
        /* Store handle for later use */
607
607
 
608
608
        pser_inf->read_total_timeout_constant = 5;
609
609
 
610
 
        return STATUS_SUCCESS;
 
610
        return RD_STATUS_SUCCESS;
611
611
}
612
612
 
613
 
static NTSTATUS
614
 
serial_close(NTHANDLE handle)
 
613
static RD_NTSTATUS
 
614
serial_close(RD_NTHANDLE handle)
615
615
{
616
616
        int i = get_device_index(handle);
617
617
        if (i >= 0)
618
618
                g_rdpdr_device[i].handle = 0;
619
619
 
620
 
        rdpdr_abort_io(handle, 0, STATUS_TIMEOUT);
 
620
        rdpdr_abort_io(handle, 0, RD_STATUS_TIMEOUT);
621
621
        close(handle);
622
 
        return STATUS_SUCCESS;
 
622
        return RD_STATUS_SUCCESS;
623
623
}
624
624
 
625
 
static NTSTATUS
626
 
serial_read(NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result)
 
625
static RD_NTSTATUS
 
626
serial_read(RD_NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result)
627
627
{
628
628
        long timeout;
629
629
        SERIAL_DEVICE *pser_inf;
678
678
                hexdump(data, *result);
679
679
#endif
680
680
 
681
 
        return STATUS_SUCCESS;
 
681
        return RD_STATUS_SUCCESS;
682
682
}
683
683
 
684
 
static NTSTATUS
685
 
serial_write(NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result)
 
684
static RD_NTSTATUS
 
685
serial_write(RD_NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result)
686
686
{
687
687
        SERIAL_DEVICE *pser_inf;
688
688
 
695
695
 
696
696
        DEBUG_SERIAL(("serial_write length %d, offset %d result %d\n", length, offset, *result));
697
697
 
698
 
        return STATUS_SUCCESS;
 
698
        return RD_STATUS_SUCCESS;
699
699
}
700
700
 
701
 
static NTSTATUS
702
 
serial_device_control(NTHANDLE handle, uint32 request, STREAM in, STREAM out)
 
701
static RD_NTSTATUS
 
702
serial_device_control(RD_NTHANDLE handle, uint32 request, STREAM in, STREAM out)
703
703
{
704
704
        int flush_mask, purge_mask;
705
705
        uint32 result, modemstate;
708
708
        struct termios *ptermios;
709
709
 
710
710
        if ((request >> 16) != FILE_DEVICE_SERIAL_PORT)
711
 
                return STATUS_INVALID_PARAMETER;
 
711
                return RD_STATUS_INVALID_PARAMETER;
712
712
 
713
713
        pser_inf = get_serial_info(handle);
714
714
        ptermios = pser_inf->ptermios;
904
904
                        if (flush_mask != 0)
905
905
                                tcflush(handle, flush_mask);
906
906
                        if (purge_mask & SERIAL_PURGE_TXABORT)
907
 
                                rdpdr_abort_io(handle, 4, STATUS_CANCELLED);
 
907
                                rdpdr_abort_io(handle, 4, RD_STATUS_CANCELLED);
908
908
                        if (purge_mask & SERIAL_PURGE_RXABORT)
909
 
                                rdpdr_abort_io(handle, 3, STATUS_CANCELLED);
 
909
                                rdpdr_abort_io(handle, 3, RD_STATUS_CANCELLED);
910
910
                        break;
911
911
                case SERIAL_WAIT_ON_MASK:
912
912
                        DEBUG_SERIAL(("serial_ioctl -> SERIAL_WAIT_ON_MASK %X\n",
918
918
                                out_uint32_le(out, result);
919
919
                                break;
920
920
                        }
921
 
                        return STATUS_PENDING;
 
921
                        return RD_STATUS_PENDING;
922
922
                        break;
923
923
                case SERIAL_SET_BREAK_ON:
924
924
                        DEBUG_SERIAL(("serial_ioctl -> SERIAL_SET_BREAK_ON\n"));
939
939
                        break;
940
940
                default:
941
941
                        unimpl("SERIAL IOCTL %d\n", request);
942
 
                        return STATUS_INVALID_PARAMETER;
 
942
                        return RD_STATUS_INVALID_PARAMETER;
943
943
        }
944
944
 
945
 
        return STATUS_SUCCESS;
 
945
        return RD_STATUS_SUCCESS;
946
946
}
947
947
 
948
 
BOOL
949
 
serial_get_event(NTHANDLE handle, uint32 * result)
 
948
RD_BOOL
 
949
serial_get_event(RD_NTHANDLE handle, uint32 * result)
950
950
{
951
951
        int index;
952
952
        SERIAL_DEVICE *pser_inf;
953
953
        int bytes;
954
 
        BOOL ret = False;
 
954
        RD_BOOL ret = False;
955
955
 
956
956
        *result = 0;
957
957
        index = get_device_index(handle);
1043
1043
}
1044
1044
 
1045
1045
/* Read timeout for a given file descripter (device) when adding fd's to select() */
1046
 
BOOL
1047
 
serial_get_timeout(NTHANDLE handle, uint32 length, uint32 * timeout, uint32 * itv_timeout)
 
1046
RD_BOOL
 
1047
serial_get_timeout(RD_NTHANDLE handle, uint32 length, uint32 * timeout, uint32 * itv_timeout)
1048
1048
{
1049
1049
        int index;
1050
1050
        SERIAL_DEVICE *pser_inf;