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

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/record/set.h

  • 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: set.h,v 1.4 2001/02/09 02:05:27 xorgcvs Exp $ */
 
2
 
 
3
/*
 
4
 
 
5
Copyright 1995, 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
 
14
included in all copies or substantial portions of the Software.
 
15
 
 
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
17
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
18
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 
19
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
 
20
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 
21
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 
22
OTHER DEALINGS IN THE SOFTWARE.
 
23
 
 
24
Except as contained in this notice, the name of The Open Group shall
 
25
not be used in advertising or otherwise to promote the sale, use or
 
26
other dealings in this Software without prior written authorization
 
27
from The Open Group.
 
28
 
 
29
*/
 
30
 
 
31
/*
 
32
          A Set Abstract Data Type (ADT) for the RECORD Extension
 
33
                           David P. Wiggins
 
34
                               7/25/95
 
35
 
 
36
    The RECORD extension server code needs to maintain sets of numbers
 
37
    that designate protocol message types.  In most cases the interval of
 
38
    numbers starts at 0 and does not exceed 255, but in a few cases (minor
 
39
    opcodes of extension requests) the maximum is 65535.  This disparity
 
40
    suggests that a single set representation may not be suitable for all
 
41
    sets, especially given that server memory is precious.  We introduce a
 
42
    set ADT to hide implementation differences so that multiple
 
43
    simultaneous set representations can exist.  A single interface is
 
44
    presented to the set user regardless of the implementation in use for
 
45
    a particular set.
 
46
 
 
47
    The existing RECORD SI appears to require only four set operations:
 
48
    create (given a list of members), destroy, see if a particular number
 
49
    is a member of the set, and iterate over the members of a set.  Though
 
50
    many more set operations are imaginable, to keep the code space down,
 
51
    we won't provide any more operations than are needed.
 
52
 
 
53
    The following types and functions/macros define the ADT.
 
54
*/
 
55
 
 
56
/* an interval of set members */
 
57
typedef struct {
 
58
    CARD16 first;
 
59
    CARD16 last;
 
60
} RecordSetInterval;
 
61
 
 
62
typedef struct _RecordSetRec *RecordSetPtr; /* primary set type */
 
63
 
 
64
typedef void *RecordSetIteratePtr;
 
65
 
 
66
/* table of function pointers for set operations.
 
67
   set users should never declare a variable of this type.
 
68
*/
 
69
typedef struct {
 
70
    void (*DestroySet)(
 
71
#if NeedNestedPrototypes
 
72
    RecordSetPtr pSet
 
73
#endif
 
74
);
 
75
    unsigned long (*IsMemberOfSet)(
 
76
#if NeedNestedPrototypes
 
77
    RecordSetPtr pSet,
 
78
    int possible_member
 
79
#endif
 
80
);
 
81
    RecordSetIteratePtr (*IterateSet)(
 
82
#if NeedNestedPrototypes
 
83
RecordSetPtr pSet,
 
84
    RecordSetIteratePtr pIter,
 
85
    RecordSetInterval *interval
 
86
#endif
 
87
);
 
88
} RecordSetOperations;
 
89
 
 
90
/* "base class" for sets.
 
91
   set users should never declare a variable of this type.
 
92
 */
 
93
typedef struct _RecordSetRec {
 
94
    RecordSetOperations *ops;
 
95
} RecordSetRec;
 
96
 
 
97
RecordSetPtr RecordCreateSet(
 
98
#if NeedFunctionPrototypes
 
99
    RecordSetInterval *intervals,
 
100
    int nintervals,
 
101
    void *pMem,
 
102
    int memsize
 
103
#endif
 
104
);
 
105
/*
 
106
    RecordCreateSet creates and returns a new set having members specified
 
107
    by intervals and nintervals.  nintervals is the number of RecordSetInterval
 
108
    structures pointed to by intervals.  The elements belonging to the new
 
109
    set are determined as follows.  For each RecordSetInterval structure, the
 
110
    elements between first and last inclusive are members of the new set.
 
111
    If a RecordSetInterval's first field is greater than its last field, the
 
112
    results are undefined.  It is valid to create an empty set (nintervals ==
 
113
    0).  If RecordCreateSet returns NULL, the set could not be created due
 
114
    to resource constraints.
 
115
*/
 
116
 
 
117
int RecordSetMemoryRequirements(
 
118
#if NeedFunctionPrototypes
 
119
    RecordSetInterval * /*pIntervals*/,
 
120
    int /*nintervals*/,
 
121
    int * /*alignment*/
 
122
#endif
 
123
);
 
124
 
 
125
#define RecordDestroySet(_pSet) \
 
126
        /* void */ (*_pSet->ops->DestroySet)(/* RecordSetPtr */ _pSet)
 
127
/*
 
128
    RecordDestroySet frees all resources used by _pSet.  _pSet should not be
 
129
    used after it is destroyed.
 
130
*/
 
131
 
 
132
#define RecordIsMemberOfSet(_pSet, _m) \
 
133
  /* unsigned long */ (*_pSet->ops->IsMemberOfSet)(/* RecordSetPtr */ _pSet, \
 
134
                                                   /* int */ _m) 
 
135
/*
 
136
    RecordIsMemberOfSet returns a non-zero value if _m is a member of
 
137
    _pSet, else it returns zero.
 
138
*/
 
139
 
 
140
#define RecordIterateSet(_pSet, _pIter, _interval) \
 
141
 /* RecordSetIteratePtr */ (*_pSet->ops->IterateSet)(/* RecordSetPtr */ _pSet,\
 
142
        /* RecordSetIteratePtr */ _pIter, /* RecordSetInterval */ _interval)
 
143
/*
 
144
    RecordIterateSet returns successive intervals of members of _pSet.  If
 
145
    _pIter is NULL, the first interval of set members is copied into _interval.
 
146
    The return value should be passed as _pIter in the next call to
 
147
    RecordIterateSet to obtain the next interval.  When the return value is
 
148
    NULL, there were no more intervals in the set, and nothing is copied into
 
149
    the _interval parameter.  Intervals appear in increasing numerical order
 
150
    with no overlap between intervals.  As such, the list of intervals produced
 
151
    by RecordIterateSet may not match the list of intervals that were passed
 
152
    in RecordCreateSet.  Typical usage:
 
153
 
 
154
        pIter = NULL;
 
155
        while (pIter = RecordIterateSet(pSet, pIter, &interval))
 
156
        {
 
157
            process interval;
 
158
        }
 
159
*/