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

« back to all changes in this revision

Viewing changes to unix/xc/lib/Xi/XChgFCtl.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: XChgFCtl.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/XChgFCtl.c,v 3.4 2002/10/16 00:37:28 dawes Exp $ */
 
49
 
 
50
/***********************************************************************
 
51
 *
 
52
 * XChangeFeedbackControl - Change the control attributes of feedbacks on
 
53
 * an extension device.
 
54
 *
 
55
 */
 
56
 
 
57
#include <X11/extensions/XI.h>
 
58
#include <X11/extensions/XIproto.h>
 
59
#include <X11/Xlibint.h>
 
60
#include <X11/extensions/XInput.h>
 
61
#include <X11/extensions/extutil.h>
 
62
#include "XIint.h"
 
63
 
 
64
int
 
65
XChangeFeedbackControl (dpy, dev, mask, f)
 
66
    register    Display         *dpy;
 
67
    XDevice                     *dev;
 
68
    unsigned    long            mask;
 
69
    XFeedbackControl            *f;
 
70
    {
 
71
    int length;
 
72
    xChangeFeedbackControlReq   *req;
 
73
    XExtDisplayInfo *info = XInput_find_display (dpy);
 
74
 
 
75
    LockDisplay (dpy);
 
76
    if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
 
77
        return (NoSuchExtension);
 
78
 
 
79
    GetReq(ChangeFeedbackControl,req);
 
80
    req->reqType = info->codes->major_opcode;
 
81
    req->ReqType = X_ChangeFeedbackControl;
 
82
    req->deviceid = dev->device_id;
 
83
    req->mask = mask;
 
84
    req->feedbackid = f->class;
 
85
 
 
86
    if (f->class == KbdFeedbackClass)
 
87
        {
 
88
        XKbdFeedbackControl     *K;
 
89
        xKbdFeedbackCtl         k;
 
90
 
 
91
        K = (XKbdFeedbackControl *) f;
 
92
        k.class = KbdFeedbackClass;
 
93
        k.length = sizeof (xKbdFeedbackCtl);
 
94
        k.id = K->id;
 
95
        k.click = K->click;
 
96
        k.percent = K->percent;
 
97
        k.pitch = K->pitch;
 
98
        k.duration = K->duration;
 
99
        k.led_mask = K->led_mask;
 
100
        k.led_values = K->led_value;
 
101
        k.key = K->key;
 
102
        k.auto_repeat_mode = K->auto_repeat_mode;
 
103
        length = ((unsigned)(k.length + 3) >> 2);
 
104
        req->length += length;
 
105
        length <<= 2;
 
106
        Data (dpy, (char *) &k, length);
 
107
        }
 
108
    else if (f->class == PtrFeedbackClass)
 
109
        {
 
110
        XPtrFeedbackControl     *P;
 
111
        xPtrFeedbackCtl         p;
 
112
 
 
113
        P = (XPtrFeedbackControl *) f;
 
114
        p.class = PtrFeedbackClass;
 
115
        p.length = sizeof (xPtrFeedbackCtl);
 
116
        p.id = P->id;
 
117
        p.num = P->accelNum;
 
118
        p.denom = P->accelDenom;
 
119
        p.thresh = P->threshold;
 
120
        length = ((unsigned)(p.length + 3) >> 2);
 
121
        req->length += length;
 
122
        length <<= 2;
 
123
        Data (dpy, (char *) &p, length);
 
124
        }
 
125
    else if (f->class == IntegerFeedbackClass)
 
126
        {
 
127
        XIntegerFeedbackControl *I;
 
128
        xIntegerFeedbackCtl     i;
 
129
 
 
130
        I = (XIntegerFeedbackControl *) f;
 
131
        i.class = IntegerFeedbackClass;
 
132
        i.length = sizeof (xIntegerFeedbackCtl);
 
133
        i.id = I->id;
 
134
        i.int_to_display = I->int_to_display;
 
135
        length = ((unsigned)(i.length + 3) >> 2);
 
136
        req->length += length;
 
137
        length <<= 2;
 
138
        Data (dpy, (char *) &i, length);
 
139
        }
 
140
    else if (f->class == StringFeedbackClass)
 
141
        {
 
142
        XStringFeedbackControl  *S;
 
143
        xStringFeedbackCtl      s;
 
144
 
 
145
        S = (XStringFeedbackControl *) f;
 
146
        s.class = StringFeedbackClass;
 
147
        s.length = sizeof (xStringFeedbackCtl) + 
 
148
                (S->num_keysyms * sizeof (KeySym));
 
149
        s.id = S->id;
 
150
        s.num_keysyms = S->num_keysyms;
 
151
        req->length += ((unsigned)(s.length + 3) >> 2);
 
152
        length = sizeof (xStringFeedbackCtl);
 
153
        Data (dpy, (char *) &s, length);
 
154
        length = (s.num_keysyms * sizeof (KeySym));
 
155
        Data (dpy, (char *) S->syms_to_display, length);
 
156
        }
 
157
    else if (f->class == BellFeedbackClass)
 
158
        {
 
159
        XBellFeedbackControl    *B;
 
160
        xBellFeedbackCtl        b;
 
161
 
 
162
        B = (XBellFeedbackControl *) f;
 
163
        b.class = BellFeedbackClass;
 
164
        b.length = sizeof (xBellFeedbackCtl);
 
165
        b.id = B->id;
 
166
        b.percent = B->percent;
 
167
        b.pitch = B->pitch;
 
168
        b.duration = B->duration;
 
169
        length = ((unsigned)(b.length + 3) >> 2);
 
170
        req->length += length;
 
171
        length <<= 2;
 
172
        Data (dpy, (char *) &b, length);
 
173
        }
 
174
    else if (f->class == LedFeedbackClass)
 
175
        {
 
176
        XLedFeedbackControl     *L;
 
177
        xLedFeedbackCtl         l;
 
178
 
 
179
        L = (XLedFeedbackControl *) f;
 
180
        l.class = LedFeedbackClass;
 
181
        l.length = sizeof (xLedFeedbackCtl);
 
182
        l.id = L->id;
 
183
        l.led_mask = L->led_mask;
 
184
        l.led_values = L->led_values;
 
185
        length = ((unsigned)(l.length + 3) >> 2);
 
186
        req->length += length;
 
187
        length <<= 2;
 
188
        Data (dpy, (char *) &l, length);
 
189
        }
 
190
    else
 
191
        {
 
192
        xFeedbackCtl            u;
 
193
 
 
194
        u.class = f->class;
 
195
        u.length = f->length - sizeof (int);
 
196
        u.id = f->id;
 
197
        length = ((unsigned)(u.length + 3) >> 2);
 
198
        req->length += length;
 
199
        length <<= 2;
 
200
        Data (dpy, (char *) &u, length);
 
201
        }
 
202
 
 
203
    UnlockDisplay(dpy);
 
204
    SyncHandle();
 
205
    return (Success);
 
206
    }
 
207