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

« back to all changes in this revision

Viewing changes to unix/xc/lib/Xt/VarCreate.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: VarCreate.c,v 1.4 2001/02/09 02:03:59 xorgcvs Exp $ */
 
2
 
 
3
/*
 
4
 
 
5
Copyright 1993 by Sun Microsystems, Inc. Mountain View, CA.
 
6
 
 
7
Permission to use, copy, modify, and distribute this
 
8
software and its documentation for any purpose and without
 
9
fee is hereby granted, provided that the above copyright
 
10
notice appear in all copies and that both that copyright
 
11
notice and this permission notice appear in supporting
 
12
documentation, and that the name Sun not be used in
 
13
advertising or publicity pertaining to distribution of the
 
14
software without specific, written prior permission.
 
15
Sun makes no representations about the suitability of
 
16
this software for any purpose.  It is provided "as is"
 
17
without express or implied warranty.
 
18
 
 
19
SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
 
20
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
 
21
NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
 
22
ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 
23
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
 
24
PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
 
25
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 
26
THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
27
 
 
28
*/
 
29
 
 
30
/*
 
31
 
 
32
Copyright 1885, 1986, 1987, 1988, 1989, 1994, 1998  The Open Group
 
33
 
 
34
Permission to use, copy, modify, distribute, and sell this software and its
 
35
documentation for any purpose is hereby granted without fee, provided that
 
36
the above copyright notice appear in all copies and that both that
 
37
copyright notice and this permission notice appear in supporting
 
38
documentation.
 
39
 
 
40
The above copyright notice and this permission notice shall be included in
 
41
all copies or substantial portions of the Software.
 
42
 
 
43
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
44
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
45
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
46
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
47
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
48
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
49
 
 
50
Except as contained in this notice, the name of The Open Group shall not be
 
51
used in advertising or otherwise to promote the sale, use or other dealings
 
52
in this Software without prior written authorization from The Open Group.
 
53
 
 
54
*/
 
55
/* $XFree86: xc/lib/Xt/VarCreate.c,v 3.7 2001/12/14 19:56:32 dawes Exp $ */
 
56
 
 
57
#include "IntrinsicI.h"
 
58
#include "StringDefs.h"
 
59
#include "Shell.h"
 
60
#include "VarargsI.h"
 
61
#include "CreateI.h"
 
62
 
 
63
#if (defined(SUNSHLIB) || defined(AIXSHLIB)) && defined(SHAREDCODE)
 
64
#define XtToolkitInitialize _XtToolkitInitialize
 
65
#endif /* (SUNSHLIB || AIXSHLIB) && SHAREDCODE */
 
66
 
 
67
static Widget
 
68
_XtVaCreateWidget(
 
69
    String      name,
 
70
    WidgetClass widget_class,
 
71
    Widget      parent,
 
72
    va_list     var,
 
73
    int         count)
 
74
{
 
75
    register Widget         widget;
 
76
    XtTypedArgList          typed_args = NULL;
 
77
    Cardinal                num_args;
 
78
 
 
79
    _XtVaToTypedArgList(var, count, &typed_args, &num_args);
 
80
 
 
81
    widget = _XtCreateWidget(name, widget_class, parent, (ArgList)NULL, 
 
82
                    (Cardinal)0, typed_args, num_args);
 
83
 
 
84
    if (typed_args != NULL) {
 
85
        XtFree((XtPointer)typed_args);
 
86
    }    
 
87
 
 
88
    return widget;
 
89
}
 
90
 
 
91
 
 
92
Widget
 
93
XtVaCreateWidget(
 
94
    _Xconst char* name,
 
95
    WidgetClass widget_class,
 
96
    Widget parent,
 
97
    ...)
 
98
{
 
99
    va_list                 var;
 
100
    register Widget         widget;
 
101
    int                     total_count, typed_count;
 
102
    WIDGET_TO_APPCON(parent);
 
103
 
 
104
    LOCK_APP(app);
 
105
    va_start(var,parent);
 
106
    _XtCountVaList(var, &total_count, &typed_count);
 
107
    va_end(var);
 
108
 
 
109
    va_start(var,parent);
 
110
    widget = _XtVaCreateWidget((String)name, widget_class, parent, var,
 
111
                                total_count);
 
112
    va_end(var);
 
113
    UNLOCK_APP(app);
 
114
    return widget;
 
115
}
 
116
 
 
117
 
 
118
Widget
 
119
XtVaCreateManagedWidget(
 
120
    _Xconst char* name,
 
121
    WidgetClass widget_class,
 
122
    Widget parent,
 
123
    ...)
 
124
{
 
125
    va_list             var;
 
126
    register Widget     widget;
 
127
    int                 total_count, typed_count;
 
128
    WIDGET_TO_APPCON(parent);
 
129
 
 
130
    LOCK_APP(app);
 
131
    va_start(var,parent);
 
132
    _XtCountVaList(var, &total_count, &typed_count);
 
133
    va_end(var);
 
134
 
 
135
    va_start(var,parent);
 
136
    widget = _XtVaCreateWidget((String)name, widget_class, parent, var,
 
137
                                total_count);
 
138
    XtManageChild(widget);
 
139
    va_end(var);
 
140
    UNLOCK_APP(app);
 
141
    return widget;
 
142
}
 
143
 
 
144
 
 
145
Widget
 
146
XtVaAppCreateShell(
 
147
    _Xconst char* name,
 
148
    _Xconst char* class,
 
149
    WidgetClass widget_class,
 
150
    Display* display,
 
151
    ...)
 
152
{
 
153
    va_list                 var;
 
154
    register Widget         widget;
 
155
    XtTypedArgList          typed_args = NULL;
 
156
    Cardinal                num_args;
 
157
    int                     total_count, typed_count;
 
158
    DPY_TO_APPCON(display);
 
159
 
 
160
    LOCK_APP(app);
 
161
    va_start(var,display);
 
162
    _XtCountVaList(var, &total_count, &typed_count);
 
163
    va_end(var);
 
164
 
 
165
    va_start(var,display);
 
166
 
 
167
    _XtVaToTypedArgList(var, total_count, &typed_args, &num_args);
 
168
    widget = _XtAppCreateShell((String)name, (String)class, widget_class,
 
169
                display, (ArgList)NULL, (Cardinal)0, typed_args, num_args);
 
170
    if (typed_args != NULL) {
 
171
        XtFree((XtPointer)typed_args);
 
172
    }
 
173
 
 
174
    va_end(var);
 
175
    UNLOCK_APP(app);
 
176
    return widget;
 
177
}
 
178
 
 
179
 
 
180
Widget
 
181
XtVaCreatePopupShell(
 
182
    _Xconst char* name,
 
183
    WidgetClass widget_class,
 
184
    Widget parent,
 
185
    ...)
 
186
{
 
187
    va_list                 var;
 
188
    register Widget         widget;
 
189
    XtTypedArgList          typed_args = NULL;
 
190
    Cardinal                num_args;
 
191
    int                     total_count, typed_count;
 
192
    WIDGET_TO_APPCON(parent);
 
193
 
 
194
    LOCK_APP(app);
 
195
    va_start(var,parent);
 
196
    _XtCountVaList(var, &total_count, &typed_count);
 
197
    va_end(var);
 
198
 
 
199
    va_start(var,parent);
 
200
 
 
201
    _XtVaToTypedArgList(var, total_count, &typed_args, &num_args);
 
202
    widget = _XtCreatePopupShell((String)name, widget_class, parent,
 
203
                (ArgList)NULL, (Cardinal)0, typed_args, num_args);
 
204
    if (typed_args != NULL) {
 
205
        XtFree((XtPointer)typed_args);
 
206
    }
 
207
 
 
208
    va_end(var);
 
209
    UNLOCK_APP(app);
 
210
    return widget;
 
211
}
 
212
 
 
213
void
 
214
XtVaSetValues(Widget widget, ...)
 
215
{
 
216
    va_list                 var;
 
217
    ArgList                 args = NULL;
 
218
    Cardinal                num_args;
 
219
    int                     total_count, typed_count;
 
220
    WIDGET_TO_APPCON(widget);
 
221
 
 
222
    LOCK_APP(app);
 
223
    va_start(var,widget);
 
224
    _XtCountVaList(var, &total_count, &typed_count);
 
225
    va_end(var);
 
226
 
 
227
    va_start(var,widget);
 
228
 
 
229
    _XtVaToArgList(widget, var, total_count, &args, &num_args);
 
230
    XtSetValues(widget, args, num_args);
 
231
    _XtFreeArgList(args, total_count, typed_count);
 
232
 
 
233
    UNLOCK_APP(app);
 
234
    va_end(var);
 
235
}
 
236
 
 
237
 
 
238
void
 
239
XtVaSetSubvalues(XtPointer base, XtResourceList resources, Cardinal num_resources, ...)
 
240
{
 
241
    va_list     var;
 
242
    ArgList     args;
 
243
    Cardinal    num_args;
 
244
    int         total_count, typed_count;               
 
245
 
 
246
    va_start(var, num_resources);
 
247
    _XtCountVaList(var, &total_count, &typed_count);
 
248
    va_end(var);
 
249
 
 
250
    if (typed_count != 0) {
 
251
        XtWarning("XtVaTypedArg is not valid in XtVaSetSubvalues()\n");
 
252
    }
 
253
 
 
254
    va_start(var, num_resources);
 
255
    _XtVaToArgList((Widget)NULL, var, total_count, &args, &num_args);
 
256
 
 
257
    XtSetSubvalues(base, resources, num_resources, args, num_args);
 
258
 
 
259
    if (num_args != 0) {
 
260
        XtFree((XtPointer)args);
 
261
    }    
 
262
 
 
263
    va_end(var);
 
264
}
 
265
 
 
266
Widget
 
267
_XtVaOpenApplication(
 
268
    XtAppContext *app_context_return,
 
269
    _Xconst char* application_class,
 
270
    XrmOptionDescList options,
 
271
    Cardinal num_options,
 
272
    int *argc_in_out,
 
273
    String *argv_in_out,
 
274
    String *fallback_resources,
 
275
    WidgetClass widget_class,
 
276
    va_list var_args)
 
277
{
 
278
    XtAppContext app_con;
 
279
    Display * dpy;
 
280
    register int saved_argc = *argc_in_out;
 
281
    Widget root;
 
282
    String attr;
 
283
    int count = 0;
 
284
    XtTypedArgList typed_args;
 
285
 
 
286
    XtToolkitInitialize(); /* cannot be moved into _XtAppInit */
 
287
    
 
288
    dpy = _XtAppInit(&app_con, (String)application_class, options, num_options,
 
289
                     argc_in_out, &argv_in_out, fallback_resources);
 
290
 
 
291
    typed_args = (XtTypedArgList) __XtMalloc((unsigned) sizeof(XtTypedArg));
 
292
    attr = va_arg (var_args, String);
 
293
    for(; attr != NULL; attr = va_arg (var_args, String)) {
 
294
        if (strcmp(attr, XtVaTypedArg) == 0) {
 
295
            typed_args[count].name = va_arg(var_args, String);
 
296
            typed_args[count].type = va_arg(var_args, String);
 
297
            typed_args[count].value = va_arg(var_args, XtArgVal);
 
298
            typed_args[count].size = va_arg(var_args, int);
 
299
        } else {
 
300
            typed_args[count].name = attr;
 
301
            typed_args[count].type = NULL;
 
302
            typed_args[count].value = va_arg(var_args, XtArgVal);
 
303
            typed_args[count].size = 0;
 
304
        }
 
305
        count++;
 
306
        typed_args = (XtTypedArgList) 
 
307
            XtRealloc((char *) typed_args, 
 
308
                       (unsigned) (count + 1) * sizeof(XtTypedArg));
 
309
    }
 
310
    typed_args[count].name = NULL;
 
311
 
 
312
    va_end (var_args);
 
313
 
 
314
    root =
 
315
        XtVaAppCreateShell( NULL, application_class, 
 
316
                            widget_class, dpy,
 
317
                            XtNscreen, (XtArgVal)DefaultScreenOfDisplay(dpy),
 
318
                            XtNargc, (XtArgVal)saved_argc,
 
319
                            XtNargv, (XtArgVal)argv_in_out,
 
320
                            XtVaNestedList, (XtVarArgsList)typed_args,
 
321
                            NULL );
 
322
   
 
323
    if (app_context_return != NULL)
 
324
        *app_context_return = app_con;
 
325
 
 
326
    XtFree((XtPointer)typed_args);
 
327
    XtFree((XtPointer)argv_in_out);
 
328
    return(root);
 
329
}
 
330
 
 
331
Widget
 
332
_XtVaAppInitialize(
 
333
    XtAppContext *app_context_return,
 
334
    _Xconst char* application_class,
 
335
    XrmOptionDescList options,
 
336
    Cardinal num_options,
 
337
    int *argc_in_out,
 
338
    String *argv_in_out,
 
339
    String *fallback_resources,
 
340
    va_list var_args)
 
341
{
 
342
    return _XtVaOpenApplication(app_context_return, application_class,
 
343
                                options, num_options,
 
344
                                argc_in_out, argv_in_out, fallback_resources,
 
345
                                applicationShellWidgetClass, var_args);
 
346
}
 
347
 
 
348
#if !((defined(SUNSHLIB) || defined(AIXSHLIB)) && defined(SHAREDCODE))
 
349
 
 
350
/*
 
351
 * If not used as a shared library, we still need a front end to 
 
352
 * _XtVaOpenApplication and to _XtVaAppInitialize.
 
353
 */
 
354
 
 
355
Widget
 
356
XtVaOpenApplication(
 
357
    XtAppContext *app_context_return,
 
358
    _Xconst char* application_class,
 
359
    XrmOptionDescList options,
 
360
    Cardinal num_options,
 
361
    int *argc_in_out,
 
362
    String *argv_in_out,
 
363
    String *fallback_resources,
 
364
    WidgetClass widget_class,
 
365
    ...)
 
366
{
 
367
    va_list     var;
 
368
 
 
369
    va_start(var, widget_class);    
 
370
    return _XtVaOpenApplication(app_context_return, (String)application_class,
 
371
                                options, num_options, argc_in_out, argv_in_out,
 
372
                                fallback_resources, widget_class, var);
 
373
}
 
374
 
 
375
Widget
 
376
XtVaAppInitialize(
 
377
    XtAppContext *app_context_return,
 
378
    _Xconst char* application_class,
 
379
    XrmOptionDescList options,
 
380
    Cardinal num_options,
 
381
    int *argc_in_out,
 
382
    String *argv_in_out,
 
383
    String *fallback_resources,
 
384
    ...)
 
385
{
 
386
    va_list     var;
 
387
 
 
388
    va_start(var, fallback_resources);    
 
389
    return _XtVaOpenApplication(app_context_return, (String)application_class,
 
390
                                options, num_options, argc_in_out, argv_in_out,
 
391
                                fallback_resources,
 
392
                                applicationShellWidgetClass, var);
 
393
}
 
394
 
 
395
#endif /* !((SUNSHLIB || AIXSHLIB) && SHAREDCODE) */
 
396