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

« back to all changes in this revision

Viewing changes to unix/xc/lib/PEX5/pl_nameset.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: pl_nameset.c,v 1.4 2001/02/09 02:03:28 xorgcvs Exp $ */
 
2
 
 
3
/******************************************************************************
 
4
 
 
5
Copyright 1992, 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
 
 
28
Copyright 1987,1991 by Digital Equipment Corporation, Maynard, Massachusetts
 
29
 
 
30
                        All Rights Reserved
 
31
 
 
32
Permission to use, copy, modify, distribute, and sell this software and its
 
33
documentation for any purpose is hereby granted without fee, provided that
 
34
the above copyright notice appear in all copies and that both that copyright
 
35
notice and this permission notice appear in supporting documentation, and that
 
36
the name of Digital not be used in advertising or publicity
 
37
pertaining to distribution of the software without specific, written prior
 
38
permission.  Digital make no representations about the suitability
 
39
of this software for any purpose.  It is provided "as is" without express or
 
40
implied warranty.
 
41
 
 
42
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 
43
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 
44
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 
45
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 
46
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 
47
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 
48
SOFTWARE.
 
49
******************************************************************************/
 
50
 
 
51
#include "PEXlib.h"
 
52
#include "PEXlibint.h"
 
53
 
 
54
 
 
55
PEXNameSet
 
56
PEXCreateNameSet (display)
 
57
 
 
58
INPUT Display           *display;
 
59
 
 
60
{
 
61
    register pexCreateNameSetReq        *req;
 
62
    char                                *pBuf;
 
63
    PEXNameSet                          ns;
 
64
 
 
65
 
 
66
    /*
 
67
     * Get a nameset resource id from X.
 
68
     */
 
69
 
 
70
    ns = XAllocID (display);
 
71
 
 
72
 
 
73
    /*
 
74
     * Lock around the critical section, for multithreading.
 
75
     */
 
76
 
 
77
    LockDisplay (display);
 
78
 
 
79
 
 
80
    /*
 
81
     * Put the request in the X request buffer.
 
82
     */
 
83
 
 
84
    PEXGetReq (CreateNameSet, pBuf);
 
85
 
 
86
    BEGIN_REQUEST_HEADER (CreateNameSet, pBuf, req);
 
87
 
 
88
    PEXStoreReqHead (CreateNameSet, req);
 
89
    req->id = ns;
 
90
 
 
91
    END_REQUEST_HEADER (CreateNameSet, pBuf, req);
 
92
 
 
93
 
 
94
    /*
 
95
     * Done, so unlock and check for synchronous-ness.
 
96
     */
 
97
 
 
98
    UnlockDisplay (display);
 
99
    PEXSyncHandle (display);
 
100
 
 
101
    return (ns);
 
102
}
 
103
 
 
104
 
 
105
void
 
106
PEXFreeNameSet (display, ns)
 
107
 
 
108
INPUT Display           *display;
 
109
INPUT PEXNameSet        ns;
 
110
 
 
111
{
 
112
    register pexFreeNameSetReq  *req;
 
113
    char                        *pBuf;
 
114
 
 
115
 
 
116
    /*
 
117
     * Lock around the critical section, for multithreading.
 
118
     */
 
119
 
 
120
    LockDisplay (display);
 
121
 
 
122
 
 
123
    /*
 
124
     * Put the request in the X request buffer.
 
125
     */
 
126
 
 
127
    PEXGetReq (FreeNameSet, pBuf);
 
128
 
 
129
    BEGIN_REQUEST_HEADER (FreeNameSet, pBuf, req);
 
130
 
 
131
    PEXStoreReqHead (FreeNameSet, req);
 
132
    req->id = ns;
 
133
 
 
134
    END_REQUEST_HEADER (FreeNameSet, pBuf, req);
 
135
 
 
136
 
 
137
    /*
 
138
     * Done, so unlock and check for synchronous-ness.
 
139
     */
 
140
 
 
141
    UnlockDisplay (display);
 
142
    PEXSyncHandle (display);
 
143
}
 
144
 
 
145
 
 
146
void
 
147
PEXCopyNameSet (display, srcNs, destNs)
 
148
 
 
149
INPUT Display           *display;
 
150
INPUT PEXNameSet        srcNs;
 
151
INPUT PEXNameSet        destNs;
 
152
 
 
153
{
 
154
    register pexCopyNameSetReq  *req;
 
155
    char                        *pBuf;
 
156
 
 
157
 
 
158
    /*
 
159
     * Lock around the critical section, for multithreading.
 
160
     */
 
161
 
 
162
    LockDisplay (display);
 
163
 
 
164
 
 
165
    /*
 
166
     * Put the request in the X request buffer.
 
167
     */
 
168
 
 
169
    PEXGetReq (CopyNameSet, pBuf);
 
170
 
 
171
    BEGIN_REQUEST_HEADER (CopyNameSet, pBuf, req);
 
172
 
 
173
    PEXStoreReqHead (CopyNameSet, req);
 
174
    req->src = srcNs;
 
175
    req->dst = destNs;
 
176
 
 
177
    END_REQUEST_HEADER (CopyNameSet, pBuf, req);
 
178
 
 
179
 
 
180
    /*
 
181
     * Done, so unlock and check for synchronous-ness.
 
182
     */
 
183
 
 
184
    UnlockDisplay (display);
 
185
    PEXSyncHandle (display);
 
186
}
 
187
 
 
188
 
 
189
Status
 
190
PEXGetNameSet (display, ns, numNamesReturn, namesReturn)
 
191
 
 
192
INPUT Display           *display;
 
193
INPUT PEXNameSet        ns;
 
194
OUTPUT unsigned long    *numNamesReturn;
 
195
OUTPUT PEXName          **namesReturn;
 
196
 
 
197
{
 
198
    register pexGetNameSetReq   *req;
 
199
    char                        *pBuf;
 
200
    pexGetNameSetReply          rep;
 
201
 
 
202
 
 
203
    /*
 
204
     * Lock around the critical section, for multithreading.
 
205
     */
 
206
 
 
207
    LockDisplay (display);
 
208
 
 
209
 
 
210
    /*
 
211
     * Put the request in the X request buffer and get a reply.
 
212
     */
 
213
 
 
214
    PEXGetReq (GetNameSet, pBuf);
 
215
 
 
216
    BEGIN_REQUEST_HEADER (GetNameSet, pBuf, req);
 
217
 
 
218
    PEXStoreReqHead (GetNameSet, req);
 
219
    req->id = ns;
 
220
 
 
221
    END_REQUEST_HEADER (GetNameSet, pBuf, req);
 
222
 
 
223
    if (_XReply (display, (xReply *)&rep, 0, xFalse) == 0)
 
224
    {
 
225
        UnlockDisplay (display);
 
226
        PEXSyncHandle (display);
 
227
        *numNamesReturn = 0;
 
228
        *namesReturn = NULL;
 
229
        return (0);             /* return an error */
 
230
    }
 
231
 
 
232
    *numNamesReturn = rep.numNames;
 
233
 
 
234
 
 
235
    /*
 
236
     * Allocate a buffer for the replies to pass back to the user.
 
237
     */
 
238
 
 
239
    *namesReturn = (PEXName *) Xmalloc (
 
240
        (unsigned) (sizeof (PEXName) * rep.numNames));
 
241
 
 
242
    XREAD_LISTOF_CARD32 (display, rep.numNames, *namesReturn);
 
243
 
 
244
 
 
245
   /*
 
246
    * Done, so unlock and check for synchronous-ness.
 
247
    */
 
248
 
 
249
    UnlockDisplay (display);
 
250
    PEXSyncHandle (display);
 
251
 
 
252
    return (1);
 
253
}
 
254
 
 
255
 
 
256
void
 
257
PEXChangeNameSet (display, ns, action, numValues, values)
 
258
 
 
259
INPUT Display           *display;
 
260
INPUT PEXNameSet        ns;
 
261
INPUT int               action;
 
262
INPUT unsigned long     numValues;
 
263
INPUT PEXName           *values;
 
264
 
 
265
{
 
266
    register pexChangeNameSetReq        *req;
 
267
    char                                *pBuf;
 
268
    int                                 size;
 
269
 
 
270
 
 
271
    /*
 
272
     * Lock around the critical section, for multithreading.
 
273
     */
 
274
 
 
275
    LockDisplay (display);
 
276
 
 
277
 
 
278
    /*
 
279
     * Put the request in the X request buffer.
 
280
     */
 
281
 
 
282
    size = numValues * SIZEOF (pexName);
 
283
    PEXGetReqExtra (ChangeNameSet, size, pBuf);
 
284
 
 
285
    BEGIN_REQUEST_HEADER (ChangeNameSet, pBuf, req);
 
286
 
 
287
    PEXStoreReqExtraHead (ChangeNameSet, size, req);
 
288
    req->ns = ns;
 
289
    req->action = action;
 
290
 
 
291
    END_REQUEST_HEADER (ChangeNameSet, pBuf, req);
 
292
 
 
293
    STORE_LISTOF_CARD32 (numValues, values, pBuf);
 
294
 
 
295
 
 
296
    /*
 
297
     * Done, so unlock and check for synchronous-ness.
 
298
     */
 
299
 
 
300
    UnlockDisplay (display);
 
301
    PEXSyncHandle (display);
 
302
}