~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/Xi/setmode.c

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Xorg: setmode.c,v 1.4 2001/02/09 02:04:35 xorgcvs Exp $ */
 
2
 
 
3
/************************************************************
 
4
 
 
5
Copyright 1989, 1998  The Open Group
 
6
 
 
7
Permission to use, copy, modify, distribute, and sell this software and its
 
8
documentation for any purpose is hereby granted without fee, provided that
 
9
the above copyright notice appear in all copies and that both that
 
10
copyright notice and this permission notice appear in supporting
 
11
documentation.
 
12
 
 
13
The above copyright notice and this permission notice shall be included in
 
14
all copies or substantial portions of the Software.
 
15
 
 
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
19
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
20
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
21
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
22
 
 
23
Except as contained in this notice, the name of The Open Group shall not be
 
24
used in advertising or otherwise to promote the sale, use or other dealings
 
25
in this Software without prior written authorization from The Open Group.
 
26
 
 
27
Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
 
28
 
 
29
                        All Rights Reserved
 
30
 
 
31
Permission to use, copy, modify, and distribute this software and its
 
32
documentation for any purpose and without fee is hereby granted,
 
33
provided that the above copyright notice appear in all copies and that
 
34
both that copyright notice and this permission notice appear in
 
35
supporting documentation, and that the name of Hewlett-Packard not be
 
36
used in advertising or publicity pertaining to distribution of the
 
37
software without specific, written prior permission.
 
38
 
 
39
HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 
40
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 
41
HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 
42
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 
43
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 
44
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 
45
SOFTWARE.
 
46
 
 
47
********************************************************/
 
48
/* $XFree86: xc/programs/Xserver/Xi/setmode.c,v 3.3 2001/12/14 19:58:59 dawes Exp $ */
 
49
 
 
50
/***********************************************************************
 
51
 *
 
52
 * Request to change the mode of an extension input device.
 
53
 *
 
54
 */
 
55
 
 
56
#define  NEED_EVENTS
 
57
#define  NEED_REPLIES
 
58
#include "X.h"                          /* for inputstr.h    */
 
59
#include "Xproto.h"                     /* Request macro     */
 
60
#include "inputstr.h"                   /* DeviceIntPtr      */
 
61
#include "XI.h"
 
62
#include "XIproto.h"
 
63
#include "XIstubs.h"
 
64
#include "extnsionst.h"
 
65
#include "extinit.h"                    /* LookupDeviceIntRec */
 
66
#include "exglobals.h"
 
67
 
 
68
#include "setmode.h"
 
69
 
 
70
/***********************************************************************
 
71
 *
 
72
 * Handle a request from a client with a different byte order.
 
73
 *
 
74
 */
 
75
 
 
76
int
 
77
SProcXSetDeviceMode(client)
 
78
    register ClientPtr client;
 
79
    {
 
80
    register char n;
 
81
 
 
82
    REQUEST(xSetDeviceModeReq);
 
83
    swaps(&stuff->length, n);
 
84
    return(ProcXSetDeviceMode(client));
 
85
    }
 
86
 
 
87
/***********************************************************************
 
88
 *
 
89
 * This procedure sets the mode of a device.
 
90
 *
 
91
 */
 
92
 
 
93
int
 
94
ProcXSetDeviceMode(client)
 
95
    register ClientPtr client;
 
96
    {
 
97
    DeviceIntPtr dev;
 
98
    xSetDeviceModeReply rep;
 
99
 
 
100
    REQUEST(xSetDeviceModeReq);
 
101
    REQUEST_SIZE_MATCH(xSetDeviceModeReq);
 
102
 
 
103
    rep.repType = X_Reply;
 
104
    rep.RepType = X_SetDeviceMode;
 
105
    rep.length = 0;
 
106
    rep.sequenceNumber = client->sequence;
 
107
 
 
108
    dev = LookupDeviceIntRec (stuff->deviceid);
 
109
    if (dev == NULL)
 
110
        {
 
111
        SendErrorToClient (client, IReqCode, X_SetDeviceMode, 0, BadDevice);
 
112
        return Success;
 
113
        }
 
114
    if (dev->valuator == NULL)
 
115
        {
 
116
        SendErrorToClient(client, IReqCode, X_SetDeviceMode, 0, BadMatch);
 
117
        return Success;
 
118
        }
 
119
    if ((dev->grab) && !SameClient(dev->grab, client))
 
120
        rep.status = AlreadyGrabbed;
 
121
    else
 
122
        rep.status = SetDeviceMode (client, dev, stuff->mode);
 
123
 
 
124
    if (rep.status == Success) 
 
125
        dev->valuator->mode = stuff->mode;
 
126
    else if (rep.status != AlreadyGrabbed)
 
127
        {
 
128
        SendErrorToClient(client, IReqCode, X_SetDeviceMode, 0, rep.status);
 
129
        return Success;
 
130
        }
 
131
 
 
132
    WriteReplyToClient (client, sizeof (xSetDeviceModeReply), &rep);
 
133
    return Success;
 
134
    }
 
135
 
 
136
/***********************************************************************
 
137
 *
 
138
 * This procedure writes the reply for the XSetDeviceMode function,
 
139
 * if the client and server have a different byte ordering.
 
140
 *
 
141
 */
 
142
 
 
143
void
 
144
SRepXSetDeviceMode (client, size, rep)
 
145
    ClientPtr   client;
 
146
    int         size;
 
147
    xSetDeviceModeReply *rep;
 
148
    {
 
149
    register char n;
 
150
 
 
151
    swaps(&rep->sequenceNumber, n);
 
152
    swapl(&rep->length, n);
 
153
    WriteToClient(client, size, (char *)rep);
 
154
    }