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

« back to all changes in this revision

Viewing changes to unix/xc/lib/Xi/XGetFCtl.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: XGetFCtl.c,v 1.4 2001/02/09 02:03:50 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/lib/Xi/XGetFCtl.c,v 3.4 2002/10/16 00:37:28 dawes Exp $ */
 
49
 
 
50
/***********************************************************************
 
51
 *
 
52
 * XGetFeedbackControl - get the feedback attributes of an extension device.
 
53
 *
 
54
 */
 
55
 
 
56
#include <X11/extensions/XI.h>
 
57
#include <X11/extensions/XIproto.h>
 
58
#include <X11/Xlibint.h>
 
59
#include <X11/Xlib.h>
 
60
#include <X11/extensions/XInput.h>
 
61
#include <X11/extensions/extutil.h>
 
62
#include "XIint.h"
 
63
 
 
64
XFeedbackState
 
65
*XGetFeedbackControl (dpy, dev, num_feedbacks)
 
66
    register    Display         *dpy;
 
67
    XDevice                     *dev;
 
68
    int                         *num_feedbacks;
 
69
    {
 
70
    int size = 0;
 
71
    int nbytes, i;
 
72
    XFeedbackState *Feedback = NULL;
 
73
    XFeedbackState *Sav = NULL;
 
74
    xFeedbackState *f = NULL;
 
75
    xFeedbackState *sav = NULL;
 
76
    xGetFeedbackControlReq *req;
 
77
    xGetFeedbackControlReply rep;
 
78
    XExtDisplayInfo *info = XInput_find_display (dpy);
 
79
 
 
80
    LockDisplay (dpy);
 
81
    if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
 
82
        return ((XFeedbackState *) NoSuchExtension);
 
83
 
 
84
    GetReq(GetFeedbackControl,req);
 
85
    req->reqType = info->codes->major_opcode;
 
86
    req->ReqType = X_GetFeedbackControl;
 
87
    req->deviceid = dev->device_id;
 
88
 
 
89
    if (! _XReply (dpy, (xReply *) &rep, 0, xFalse)) 
 
90
        {
 
91
        UnlockDisplay(dpy);
 
92
        SyncHandle();
 
93
        return (XFeedbackState *) NULL;
 
94
        }
 
95
    if (rep.length > 0) 
 
96
        {
 
97
        *num_feedbacks = rep.num_feedbacks;
 
98
        nbytes = (long)rep.length << 2;
 
99
        f = (xFeedbackState *) Xmalloc((unsigned) nbytes);
 
100
        if (!f)
 
101
            {
 
102
            _XEatData (dpy, (unsigned long) nbytes);
 
103
            UnlockDisplay(dpy);
 
104
            SyncHandle();
 
105
            return (XFeedbackState *) NULL;
 
106
            }
 
107
        sav = f;
 
108
        _XRead (dpy, (char *) f, nbytes);
 
109
 
 
110
        for (i=0; i<*num_feedbacks; i++)
 
111
            {
 
112
            switch (f->class)
 
113
                {
 
114
                case KbdFeedbackClass:
 
115
                    size += sizeof (XKbdFeedbackState);
 
116
                    break;
 
117
                case PtrFeedbackClass:
 
118
                    size += sizeof (XPtrFeedbackState);
 
119
                    break;
 
120
                case IntegerFeedbackClass:
 
121
                    size += sizeof (XIntegerFeedbackState);
 
122
                    break;
 
123
                case StringFeedbackClass:
 
124
                    {
 
125
                    xStringFeedbackState *strf = (xStringFeedbackState *) f;
 
126
 
 
127
                    size += sizeof (XStringFeedbackState) + 
 
128
                        (strf->num_syms_supported * sizeof (KeySym));
 
129
                    }
 
130
                    break;
 
131
                case LedFeedbackClass:
 
132
                    size += sizeof (XLedFeedbackState);
 
133
                    break;
 
134
                case BellFeedbackClass:
 
135
                    size += sizeof (XBellFeedbackState);
 
136
                    break;
 
137
                default:
 
138
                    size += f->length;
 
139
                    break;
 
140
                }
 
141
            f = (xFeedbackState *) ((char *) f + f->length);
 
142
            }
 
143
 
 
144
        Feedback = (XFeedbackState *) Xmalloc((unsigned) size);
 
145
        if (!Feedback)
 
146
            {
 
147
            UnlockDisplay(dpy);
 
148
            SyncHandle();
 
149
            return (XFeedbackState *) NULL;
 
150
            }
 
151
        Sav = Feedback;
 
152
 
 
153
        f = sav;
 
154
        for (i=0; i<*num_feedbacks; i++)
 
155
            {
 
156
            switch (f->class)
 
157
                {
 
158
                case KbdFeedbackClass:
 
159
                    {
 
160
                    xKbdFeedbackState *k;
 
161
                    XKbdFeedbackState *K;
 
162
                    k = (xKbdFeedbackState *) f;
 
163
                    K = (XKbdFeedbackState *) Feedback;
 
164
 
 
165
                    K->class = k->class;
 
166
                    K->length = sizeof (XKbdFeedbackState);
 
167
                    K->id = k->id;
 
168
                    K->click = k->click;
 
169
                    K->percent = k->percent;
 
170
                    K->pitch = k->pitch;
 
171
                    K->duration = k->duration;
 
172
                    K->led_mask = k->led_mask;
 
173
                    K->global_auto_repeat = k->global_auto_repeat;
 
174
                    memcpy ((char *) &K->auto_repeats[0],
 
175
                            (char *) &k->auto_repeats[0], 32);
 
176
                    break;
 
177
                    }
 
178
                case PtrFeedbackClass:
 
179
                    {
 
180
                    xPtrFeedbackState *p;
 
181
                    XPtrFeedbackState *P;
 
182
                    p = (xPtrFeedbackState *) f;
 
183
                    P = (XPtrFeedbackState *) Feedback;
 
184
 
 
185
                    P->class = p->class;
 
186
                    P->length = sizeof (XPtrFeedbackState);
 
187
                    P->id = p->id;
 
188
                    P->accelNum = p->accelNum;
 
189
                    P->accelDenom = p->accelDenom;
 
190
                    P->threshold = p->threshold;
 
191
                    break;
 
192
                    }
 
193
                case IntegerFeedbackClass:
 
194
                    {
 
195
                    xIntegerFeedbackState *i;
 
196
                    XIntegerFeedbackState *I;
 
197
                    i = (xIntegerFeedbackState *) f;
 
198
                    I = (XIntegerFeedbackState *) Feedback;
 
199
 
 
200
                    I->class = i->class;
 
201
                    I->length = sizeof (XIntegerFeedbackState);
 
202
                    I->id = i->id;
 
203
                    I->resolution = i->resolution;
 
204
                    I->minVal = i->min_value;
 
205
                    I->maxVal = i->max_value;
 
206
                    break;
 
207
                    }
 
208
                case StringFeedbackClass:
 
209
                    {
 
210
                    xStringFeedbackState *s;
 
211
                    XStringFeedbackState *S;
 
212
                    s = (xStringFeedbackState *) f;
 
213
                    S = (XStringFeedbackState *) Feedback;
 
214
 
 
215
                    S->class = s->class;
 
216
                    S->length = sizeof (XStringFeedbackState) + 
 
217
                        (s->num_syms_supported * sizeof (KeySym));
 
218
                    S->id = s->id;
 
219
                    S->max_symbols = s->max_symbols;
 
220
                    S->num_syms_supported = s->num_syms_supported;
 
221
                    S->syms_supported = (KeySym *) (S+1);
 
222
                    memcpy ((char *) S->syms_supported, (char *) (s+1),
 
223
                            (S->num_syms_supported * sizeof (KeySym)));
 
224
                    break;
 
225
                    }
 
226
                case LedFeedbackClass:
 
227
                    {
 
228
                    xLedFeedbackState *l;
 
229
                    XLedFeedbackState *L;
 
230
                    l = (xLedFeedbackState *) f;
 
231
                    L = (XLedFeedbackState *) Feedback;
 
232
 
 
233
                    L->class = l->class;
 
234
                    L->length = sizeof (XLedFeedbackState);
 
235
                    L->id = l->id;
 
236
                    L->led_values = l->led_values;
 
237
                    L->led_mask = l->led_mask;
 
238
                    break;
 
239
                    }
 
240
                case BellFeedbackClass:
 
241
                    {
 
242
                    xBellFeedbackState *b;
 
243
                    XBellFeedbackState *B;
 
244
                    b = (xBellFeedbackState *) f;
 
245
                    B = (XBellFeedbackState *) Feedback;
 
246
 
 
247
                    B->class = b->class;
 
248
                    B->length = sizeof (XBellFeedbackState);
 
249
                    B->id = b->id;
 
250
                    B->percent = b->percent;
 
251
                    B->pitch = b->pitch;
 
252
                    B->duration = b->duration;
 
253
                    break;
 
254
                    }
 
255
                default:
 
256
                    break;
 
257
                }
 
258
            f = (xFeedbackState *) ((char *) f + f->length);
 
259
            Feedback = (XFeedbackState *) ((char *) Feedback+Feedback->length);
 
260
            }
 
261
        XFree ((char *)sav);
 
262
        }
 
263
 
 
264
    UnlockDisplay(dpy);
 
265
    SyncHandle();
 
266
    return (Sav);
 
267
    }
 
268
 
 
269
void XFreeFeedbackList (list)
 
270
    XFeedbackState *list;
 
271
    {
 
272
    XFree ((char *)list);
 
273
    }