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

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/Xi/chgdctl.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: chgdctl.c,v 1.4 2001/02/09 02:04:33 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/chgdctl.c,v 3.4 2001/12/14 19:58:54 dawes Exp $ */
 
49
 
 
50
/********************************************************************
 
51
 *
 
52
 *  Change Device control attributes for an extension device.
 
53
 *
 
54
 */
 
55
 
 
56
#define  NEED_EVENTS                    /* for inputstr.h    */
 
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"                    /* control constants */
 
63
#include "XIstubs.h"
 
64
 
 
65
#include "extnsionst.h"
 
66
#include "extinit.h"                    /* LookupDeviceIntRec */
 
67
#include "exglobals.h"
 
68
 
 
69
#include "chgdctl.h"
 
70
 
 
71
/***********************************************************************
 
72
 *
 
73
 * This procedure changes the control attributes for an extension device,
 
74
 * for clients on machines with a different byte ordering than the server.
 
75
 *
 
76
 */
 
77
 
 
78
int
 
79
SProcXChangeDeviceControl(client)
 
80
    register ClientPtr client;
 
81
    {
 
82
    register char n;
 
83
 
 
84
    REQUEST(xChangeDeviceControlReq);
 
85
    swaps(&stuff->length, n);
 
86
    REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
 
87
    swaps(&stuff->control, n);
 
88
    return(ProcXChangeDeviceControl(client));
 
89
    }
 
90
 
 
91
/***********************************************************************
 
92
 *
 
93
 * Change the control attributes.
 
94
 *
 
95
 */
 
96
 
 
97
int
 
98
ProcXChangeDeviceControl(client)
 
99
    ClientPtr client;
 
100
    {
 
101
    unsigned len;
 
102
    int i, status;
 
103
    DeviceIntPtr dev;
 
104
    xDeviceResolutionCtl *r;
 
105
    xChangeDeviceControlReply rep;
 
106
    AxisInfoPtr a;
 
107
    CARD32 *resolution;
 
108
 
 
109
    REQUEST(xChangeDeviceControlReq);
 
110
    REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
 
111
 
 
112
    len = stuff->length - (sizeof(xChangeDeviceControlReq) >>2);
 
113
    dev = LookupDeviceIntRec (stuff->deviceid);
 
114
    if (dev == NULL)
 
115
        {
 
116
        SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0, 
 
117
                BadDevice);
 
118
        return Success;
 
119
        }
 
120
 
 
121
    rep.repType = X_Reply;
 
122
    rep.RepType = X_ChangeDeviceControl;
 
123
    rep.length = 0;
 
124
    rep.sequenceNumber = client->sequence;
 
125
 
 
126
    switch (stuff->control) 
 
127
        {
 
128
        case DEVICE_RESOLUTION:
 
129
            r = (xDeviceResolutionCtl *) &stuff[1];
 
130
            if ((len < (sizeof(xDeviceResolutionCtl)>>2)) ||
 
131
                (len != (sizeof(xDeviceResolutionCtl)>>2) +
 
132
                 r->num_valuators))
 
133
                {
 
134
                SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 
 
135
                        0, BadLength);
 
136
                return Success;
 
137
                }
 
138
            if (!dev->valuator)
 
139
                {
 
140
                SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0, 
 
141
                    BadMatch);
 
142
                return Success;
 
143
                }
 
144
            if ((dev->grab) && !SameClient(dev->grab, client))
 
145
                {
 
146
                rep.status = AlreadyGrabbed;
 
147
                WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), 
 
148
                    &rep);
 
149
                return Success;
 
150
                }
 
151
            resolution = (CARD32 *) (r + 1);
 
152
            if (r->first_valuator + r->num_valuators > dev->valuator->numAxes)
 
153
                {
 
154
                SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0, 
 
155
                    BadValue);
 
156
                return Success;
 
157
                }
 
158
            status = ChangeDeviceControl(client, dev, (xDeviceCtl*) r);
 
159
            if (status == Success)
 
160
                {
 
161
                a = &dev->valuator->axes[r->first_valuator];
 
162
                for (i=0; i<r->num_valuators; i++)
 
163
                    if (*(resolution+i) < (a+i)->min_resolution ||
 
164
                        *(resolution+i) > (a+i)->max_resolution)
 
165
                        {
 
166
                        SendErrorToClient (client, IReqCode, 
 
167
                            X_ChangeDeviceControl, 0, BadValue);
 
168
                        return Success;
 
169
                        }
 
170
                for (i=0; i<r->num_valuators; i++)
 
171
                    (a++)->resolution = *resolution++; 
 
172
                }
 
173
            else if (status == DeviceBusy)
 
174
                {
 
175
                rep.status = DeviceBusy;
 
176
                WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), 
 
177
                    &rep);
 
178
                return Success;
 
179
                }
 
180
            else 
 
181
                {
 
182
                SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0, 
 
183
                    BadMatch);
 
184
                return Success;
 
185
                }
 
186
            break;
 
187
        default:
 
188
            SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0, 
 
189
                BadValue);
 
190
            return Success;
 
191
        }
 
192
    WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
 
193
    return Success;
 
194
    }
 
195
 
 
196
/***********************************************************************
 
197
 *
 
198
 * This procedure writes the reply for the xChangeDeviceControl function,
 
199
 * if the client and server have a different byte ordering.
 
200
 *
 
201
 */
 
202
 
 
203
void
 
204
SRepXChangeDeviceControl (client, size, rep)
 
205
    ClientPtr   client;
 
206
    int         size;
 
207
    xChangeDeviceControlReply   *rep;
 
208
    {
 
209
    register char n;
 
210
 
 
211
    swaps(&rep->sequenceNumber, n);
 
212
    swapl(&rep->length, n);
 
213
    WriteToClient(client, size, (char *)rep);
 
214
    }
 
215