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

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/Xi/getdctl.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: getdctl.c,v 1.4 2001/02/09 02:04:34 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/getdctl.c,v 3.4 2001/12/14 19:58:56 dawes Exp $ */
 
49
 
 
50
/********************************************************************
 
51
 *
 
52
 *  Get 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"
 
63
#include "extnsionst.h"
 
64
#include "extinit.h"                    /* LookupDeviceIntRec */
 
65
#include "exglobals.h"
 
66
 
 
67
#include "getdctl.h"
 
68
 
 
69
/***********************************************************************
 
70
 *
 
71
 * This procedure gets the control attributes for an extension device,
 
72
 * for clients on machines with a different byte ordering than the server.
 
73
 *
 
74
 */
 
75
 
 
76
int
 
77
SProcXGetDeviceControl(client)
 
78
    register ClientPtr client;
 
79
    {
 
80
    register char n;
 
81
 
 
82
    REQUEST(xGetDeviceControlReq);
 
83
    swaps(&stuff->length, n);
 
84
    REQUEST_SIZE_MATCH(xGetDeviceControlReq);
 
85
    swaps(&stuff->control, n);
 
86
    return(ProcXGetDeviceControl(client));
 
87
    }
 
88
 
 
89
/***********************************************************************
 
90
 *
 
91
 * Get the state of the specified device control.
 
92
 *
 
93
 */
 
94
 
 
95
int
 
96
ProcXGetDeviceControl(client)
 
97
    ClientPtr client;
 
98
    {
 
99
    int total_length = 0;
 
100
    char *buf, *savbuf;
 
101
    register DeviceIntPtr dev;
 
102
    xGetDeviceControlReply rep;
 
103
 
 
104
    REQUEST(xGetDeviceControlReq);
 
105
    REQUEST_SIZE_MATCH(xGetDeviceControlReq);
 
106
 
 
107
    dev = LookupDeviceIntRec (stuff->deviceid);
 
108
    if (dev == NULL)
 
109
        {
 
110
        SendErrorToClient (client, IReqCode, X_GetDeviceControl, 0, 
 
111
                BadDevice);
 
112
        return Success;
 
113
        }
 
114
 
 
115
    rep.repType = X_Reply;
 
116
    rep.RepType = X_GetDeviceControl;
 
117
    rep.length = 0;
 
118
    rep.sequenceNumber = client->sequence;
 
119
 
 
120
    switch (stuff->control)
 
121
        {
 
122
        case DEVICE_RESOLUTION:
 
123
            if (!dev->valuator)
 
124
                {
 
125
                SendErrorToClient (client, IReqCode, X_GetDeviceControl, 0, 
 
126
                    BadMatch);
 
127
                return Success;
 
128
                }
 
129
            total_length = sizeof (xDeviceResolutionState) +
 
130
                (3 * sizeof(int) * dev->valuator->numAxes);
 
131
            break;
 
132
        default:
 
133
            SendErrorToClient (client, IReqCode, X_GetDeviceControl, 0, 
 
134
                BadValue);
 
135
            return Success;
 
136
        }
 
137
 
 
138
    buf = (char *) xalloc (total_length);
 
139
    if (!buf)
 
140
        {
 
141
        SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, 
 
142
                BadAlloc);
 
143
        return Success;
 
144
        }
 
145
    savbuf=buf;
 
146
 
 
147
    switch (stuff->control)
 
148
        {
 
149
        case DEVICE_RESOLUTION:
 
150
            CopySwapDeviceResolution(client, dev->valuator, buf,
 
151
                total_length);
 
152
            break;
 
153
        default:
 
154
            break;
 
155
        }
 
156
 
 
157
    rep.length = (total_length+3) >> 2;
 
158
    WriteReplyToClient(client, sizeof(xGetDeviceControlReply), &rep);
 
159
    WriteToClient(client, total_length, savbuf);
 
160
    xfree (savbuf);
 
161
    return Success;
 
162
    }
 
163
 
 
164
/***********************************************************************
 
165
 *
 
166
 * This procedure copies DeviceResolution data, swapping if necessary.
 
167
 *
 
168
 */
 
169
 
 
170
void
 
171
CopySwapDeviceResolution (client, v, buf, length)
 
172
    ClientPtr           client;
 
173
    ValuatorClassPtr    v;
 
174
    char                *buf;
 
175
    int                 length;
 
176
    {
 
177
    register char       n;
 
178
    AxisInfoPtr a;
 
179
    xDeviceResolutionState *r;
 
180
    int i, *iptr;
 
181
 
 
182
    r = (xDeviceResolutionState *) buf;
 
183
    r->control = DEVICE_RESOLUTION;
 
184
    r->length =  length;
 
185
    r->num_valuators =  v->numAxes;
 
186
    buf += sizeof (xDeviceResolutionState);
 
187
    iptr = (int *) buf;
 
188
    for (i=0,a=v->axes; i<v->numAxes; i++,a++)
 
189
        *iptr++ = a->resolution;
 
190
    for (i=0,a=v->axes; i<v->numAxes; i++,a++)
 
191
        *iptr++ = a->min_resolution;
 
192
    for (i=0,a=v->axes; i<v->numAxes; i++,a++)
 
193
        *iptr++ = a->max_resolution;
 
194
    if (client->swapped)
 
195
        {
 
196
        swaps (&r->control,n);
 
197
        swaps (&r->length,n);
 
198
        swapl (&r->num_valuators,n);
 
199
        iptr = (int *) buf;
 
200
        for (i=0; i < (3 * v->numAxes); i++,iptr++)
 
201
            {
 
202
            swapl (iptr,n);
 
203
            }
 
204
        }
 
205
    }
 
206
 
 
207
/***********************************************************************
 
208
 *
 
209
 * This procedure writes the reply for the xGetDeviceControl function,
 
210
 * if the client and server have a different byte ordering.
 
211
 *
 
212
 */
 
213
 
 
214
void
 
215
SRepXGetDeviceControl (client, size, rep)
 
216
    ClientPtr   client;
 
217
    int         size;
 
218
    xGetDeviceControlReply      *rep;
 
219
    {
 
220
    register char n;
 
221
 
 
222
    swaps(&rep->sequenceNumber, n);
 
223
    swapl(&rep->length, n);
 
224
    WriteToClient(client, size, (char *)rep);
 
225
    }
 
226