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

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/hw/kdrive/linux/bus.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
/*
 
2
 * $XFree86: xc/programs/Xserver/hw/kdrive/linux/bus.c,v 1.3 2001/10/12 06:33:10 keithp Exp $
 
3
 *
 
4
 * Copyright � 2000 Keith Packard, member of The XFree86 Project, Inc.
 
5
 *
 
6
 * Permission to use, copy, modify, distribute, and sell this software and its
 
7
 * documentation for any purpose is hereby granted without fee, provided that
 
8
 * the above copyright notice appear in all copies and that both that
 
9
 * copyright notice and this permission notice appear in supporting
 
10
 * documentation, and that the name of Keith Packard not be used in
 
11
 * advertising or publicity pertaining to distribution of the software without
 
12
 * specific, written prior permission.  Keith Packard makes no
 
13
 * representations about the suitability of this software for any purpose.  It
 
14
 * is provided "as is" without express or implied warranty.
 
15
 *
 
16
 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
17
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 
18
 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
19
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 
20
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 
21
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 
22
 * PERFORMANCE OF THIS SOFTWARE.
 
23
 */
 
24
 
 
25
#define NEED_EVENTS
 
26
#include "X.h"
 
27
#include "Xproto.h"
 
28
#include "inputstr.h"
 
29
#include "scrnintstr.h"
 
30
#include "kdrive.h"
 
31
#include "Xpoll.h"
 
32
 
 
33
/* /dev/adbmouse is a busmouse */
 
34
 
 
35
void
 
36
BusRead (int adbPort, void *closure)
 
37
{
 
38
    unsigned char   buf[3];
 
39
    unsigned char   *b;
 
40
    int             n;
 
41
    int             dx, dy;
 
42
    unsigned long   flags;
 
43
 
 
44
    n = read (adbPort, buf, 3);
 
45
    if (n == 3)
 
46
    {
 
47
        flags = KD_MOUSE_DELTA;
 
48
        dx = (char) buf[1];
 
49
        dy = -(char) buf[2];
 
50
        if ((buf[0] & 4) == 0)
 
51
            flags |= KD_BUTTON_1;
 
52
        if ((buf[0] & 2) == 0)
 
53
            flags |= KD_BUTTON_2;
 
54
        if ((buf[0] & 1) == 0)
 
55
            flags |= KD_BUTTON_3;
 
56
        KdEnqueueMouseEvent (kdMouseInfo, flags, dx, dy);
 
57
    }
 
58
}
 
59
 
 
60
char    *BusNames[] = {
 
61
    "/dev/adbmouse",
 
62
    "/dev/mouse",
 
63
};
 
64
 
 
65
#define NUM_BUS_NAMES   (sizeof (BusNames) / sizeof (BusNames[0]))
 
66
 
 
67
int     BusInputType;
 
68
 
 
69
int
 
70
BusInit (void)
 
71
{
 
72
    int     i;
 
73
    int     busPort;
 
74
    int     n = 0;
 
75
 
 
76
    if (!BusInputType)
 
77
        BusInputType = KdAllocInputType ();
 
78
    
 
79
    for (i = 0; i < NUM_BUS_NAMES; i++)
 
80
    {
 
81
        busPort = open (BusNames[i], 0);
 
82
        {
 
83
            KdRegisterFd (BusInputType, busPort, BusRead, 0);
 
84
            n++;
 
85
        }
 
86
    }
 
87
    return n;
 
88
}
 
89
 
 
90
void
 
91
BusFini (void)
 
92
{
 
93
    KdUnregisterFds (BusInputType, TRUE);
 
94
}
 
95
 
 
96
KdMouseFuncs BusMouseFuncs = {
 
97
    BusInit,
 
98
    BusFini
 
99
};