~sbeattie/ubuntu/lucid/vnc4/lp556147

« back to all changes in this revision

Viewing changes to unix/xc/lib/Xi/XGMotion.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: XGMotion.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/XGMotion.c,v 3.4 2002/10/16 00:37:28 dawes Exp $ */
 
49
 
 
50
/***********************************************************************
 
51
 *
 
52
 * XGetDeviceMotionEvents - Get the motion history of an input device.
 
53
 *
 
54
 */
 
55
 
 
56
#include <X11/extensions/XI.h>
 
57
#include <X11/extensions/XIproto.h>
 
58
#include <X11/Xlibint.h>
 
59
#include <X11/extensions/XInput.h>
 
60
#include <X11/extensions/extutil.h>
 
61
#include "XIint.h"
 
62
 
 
63
XDeviceTimeCoord
 
64
*XGetDeviceMotionEvents (dpy, dev, start, stop, nEvents, mode, axis_count)
 
65
    register    Display *dpy;
 
66
    XDevice             *dev;
 
67
    Time                start;
 
68
    Time                stop;
 
69
    int                 *nEvents;
 
70
    int                 *mode;
 
71
    int                 *axis_count;
 
72
    {       
 
73
    xGetDeviceMotionEventsReq   *req;
 
74
    xGetDeviceMotionEventsReply         rep;
 
75
    XDeviceTimeCoord *tc;
 
76
    int *data, *bufp, *readp, *savp;
 
77
    long size, size2;
 
78
    int  i, j;
 
79
    XExtDisplayInfo *info = XInput_find_display (dpy);
 
80
 
 
81
    LockDisplay (dpy);
 
82
    if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
 
83
        return ((XDeviceTimeCoord *) NoSuchExtension);
 
84
 
 
85
    GetReq(GetDeviceMotionEvents,req);          
 
86
    req->reqType = info->codes->major_opcode;
 
87
    req->ReqType = X_GetDeviceMotionEvents;
 
88
    req->start = start;
 
89
    req->stop = stop;
 
90
    req->deviceid = dev->device_id;
 
91
 
 
92
    if (!_XReply (dpy, (xReply *)&rep, 0, xFalse)) {
 
93
        UnlockDisplay(dpy);
 
94
        SyncHandle();
 
95
        *nEvents = 0;
 
96
        return (NULL);
 
97
        }
 
98
 
 
99
    *mode = rep.mode;
 
100
    *axis_count = rep.axes;
 
101
    *nEvents = rep.nEvents;
 
102
    if (!rep.nEvents)
 
103
        {
 
104
        UnlockDisplay(dpy);
 
105
        SyncHandle();
 
106
        return (NULL);
 
107
        }
 
108
    size = rep.length << 2;
 
109
    size2 = rep.nEvents * 
 
110
        (sizeof (XDeviceTimeCoord) + (rep.axes * sizeof (int)));
 
111
    savp = readp = (int *) Xmalloc (size);
 
112
    bufp = (int *) Xmalloc (size2);
 
113
    if (!bufp || !savp)
 
114
        {
 
115
        *nEvents = 0;
 
116
        _XEatData (dpy, (unsigned long) size);
 
117
        UnlockDisplay(dpy);
 
118
        SyncHandle();
 
119
        return (NULL);
 
120
        }
 
121
    _XRead (dpy, (char *) readp, size);
 
122
 
 
123
    tc = (XDeviceTimeCoord *) bufp;
 
124
    data = (int *) (tc + rep.nEvents);
 
125
    for (i=0; i<*nEvents; i++,tc++)
 
126
        {
 
127
        tc->time = *readp++;
 
128
        tc->data = data;
 
129
        for (j=0; j<*axis_count; j++)
 
130
            *data++ = *readp++;
 
131
        }
 
132
    XFree ((char *)savp);
 
133
    UnlockDisplay(dpy);
 
134
    SyncHandle();
 
135
    return ((XDeviceTimeCoord *) bufp);
 
136
    }
 
137
 
 
138
void XFreeDeviceMotionEvents (events)
 
139
    XDeviceTimeCoord *events;
 
140
    {
 
141
    XFree ((char *)events);
 
142
    }