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

« back to all changes in this revision

Viewing changes to unix/xc/programs/xieperf/query.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: query.c,v 1.4 2001/02/09 02:05:48 xorgcvs Exp $ */
 
2
 
 
3
/**** module query.c ****/
 
4
/******************************************************************************
 
5
 
 
6
Copyright 1993, 1994, 1998  The Open Group
 
7
 
 
8
Permission to use, copy, modify, distribute, and sell this software and its
 
9
documentation for any purpose is hereby granted without fee, provided that
 
10
the above copyright notice appear in all copies and that both that
 
11
copyright notice and this permission notice appear in supporting
 
12
documentation.
 
13
 
 
14
The above copyright notice and this permission notice shall be included in
 
15
all copies or substantial portions of the Software.
 
16
 
 
17
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
18
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
19
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
20
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
21
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
22
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
23
 
 
24
Except as contained in this notice, the name of The Open Group shall not be
 
25
used in advertising or otherwise to promote the sale, use or other dealings
 
26
in this Software without prior written authorization from The Open Group.
 
27
 
 
28
 
 
29
                                NOTICE
 
30
                              
 
31
This software is being provided by AGE Logic, Inc. under the
 
32
following license.  By obtaining, using and/or copying this software,
 
33
you agree that you have read, understood, and will comply with these
 
34
terms and conditions:
 
35
 
 
36
     Permission to use, copy, modify, distribute and sell this
 
37
     software and its documentation for any purpose and without
 
38
     fee or royalty and to grant others any or all rights granted
 
39
     herein is hereby granted, provided that you agree to comply
 
40
     with the following copyright notice and statements, including
 
41
     the disclaimer, and that the same appears on all copies and
 
42
     derivative works of the software and documentation you make.
 
43
     
 
44
     "Copyright 1993, 1994 by AGE Logic, Inc."
 
45
     
 
46
     THIS SOFTWARE IS PROVIDED "AS IS".  AGE LOGIC MAKES NO
 
47
     REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.  By way of
 
48
     example, but not limitation, AGE LOGIC MAKE NO
 
49
     REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS
 
50
     FOR ANY PARTICULAR PURPOSE OR THAT THE SOFTWARE DOES NOT
 
51
     INFRINGE THIRD-PARTY PROPRIETARY RIGHTS.  AGE LOGIC 
 
52
     SHALL BEAR NO LIABILITY FOR ANY USE OF THIS SOFTWARE.  IN NO
 
53
     EVENT SHALL EITHER PARTY BE LIABLE FOR ANY INDIRECT,
 
54
     INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS
 
55
     OF PROFITS, REVENUE, DATA OR USE, INCURRED BY EITHER PARTY OR
 
56
     ANY THIRD PARTY, WHETHER IN AN ACTION IN CONTRACT OR TORT OR
 
57
     BASED ON A WARRANTY, EVEN IF AGE LOGIC LICENSEES
 
58
     HEREUNDER HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
 
59
     DAMAGES.
 
60
    
 
61
     The name of AGE Logic, Inc. may not be used in
 
62
     advertising or publicity pertaining to this software without
 
63
     specific, written prior permission from AGE Logic.
 
64
 
 
65
     Title to this software shall at all times remain with AGE
 
66
     Logic, Inc.
 
67
*****************************************************************************
 
68
  
 
69
        query.c -- query flo element test 
 
70
 
 
71
        Syd Logan -- AGE Logic, Inc.
 
72
  
 
73
*****************************************************************************/
 
74
/* $XFree86: xc/programs/xieperf/query.c,v 1.6 2001/12/14 20:01:51 dawes Exp $ */
 
75
 
 
76
 
 
77
#include "xieperf.h"
 
78
#include <stdio.h>
 
79
 
 
80
static XiePhotomap XIEPhotomap;
 
81
static XieLut   PhotofloTestLut1, PhotofloTestLut2;
 
82
static XieColorList XIEColorList;
 
83
 
 
84
static int flo_elements;
 
85
static XiePhotoElement *flograph;
 
86
static XiePhotoflo flo;
 
87
 
 
88
int 
 
89
InitQueryTechniques(XParms xp, Parms p, int reps)
 
90
{
 
91
        return reps;
 
92
}
 
93
 
 
94
int 
 
95
InitQueryColorList(XParms xp, Parms p, int reps)
 
96
{
 
97
        /* allocate a color list */
 
98
 
 
99
        if ( !(XIEColorList = XieCreateColorList( xp->d ) ) )
 
100
        {
 
101
                fprintf( stderr, "XieCreateColorList failed\n" );
 
102
                reps = 0;
 
103
        }
 
104
        return reps;
 
105
}
 
106
 
 
107
int 
 
108
InitQueryPhotomap(XParms xp, Parms p, int reps)
 
109
{
 
110
        if ( ( XIEPhotomap = 
 
111
                GetXIEPhotomap( xp, p, 1 ) ) == ( XiePhotomap ) NULL )
 
112
        {
 
113
                reps = 0;
 
114
        }
 
115
        return reps;
 
116
}
 
117
 
 
118
int 
 
119
InitQueryPhotoflo(XParms xp, Parms p, int reps)
 
120
{
 
121
        int     lutSize, lutLevels;
 
122
        unsigned char   *lut1, *lut2;
 
123
        Bool    merge;
 
124
        XieLTriplet start;
 
125
 
 
126
        flograph = ( XiePhotoElement * ) NULL;
 
127
        flo = ( XiePhotoflo ) NULL;
 
128
        lut1 = lut2 = ( unsigned char * ) NULL;
 
129
        PhotofloTestLut1 = PhotofloTestLut2 = ( XieLut ) NULL;
 
130
 
 
131
        flo_elements = 2;
 
132
        flograph = XieAllocatePhotofloGraph(flo_elements);
 
133
        lutSize = ( ( QueryParms * ) p->ts )->lutSize;
 
134
        lutLevels = ( ( QueryParms * ) p->ts )->lutLevels;
 
135
        if ( flograph == ( XiePhotoElement * ) NULL )
 
136
        {
 
137
                fprintf( stderr, "XieAllocatePhotofloGraph failed\n" );
 
138
                reps = 0;
 
139
        }
 
140
        else
 
141
        {
 
142
                lut1 = (unsigned char *)
 
143
                        malloc( lutSize * sizeof( unsigned char ) );
 
144
                if ( lut1 == ( unsigned char * ) NULL )
 
145
                        reps = 0;
 
146
                else
 
147
                {
 
148
                        lut2 = (unsigned char *)
 
149
                                malloc( lutSize * sizeof( unsigned char ) );
 
150
                        if ( lut2 == ( unsigned char * ) NULL )
 
151
                        {
 
152
                                reps = 0;
 
153
                        }
 
154
                }
 
155
        }
 
156
        
 
157
        if ( reps )
 
158
        {
 
159
                if ( ( PhotofloTestLut1 = GetXIELut( xp, p, lut1, lutSize,
 
160
                        lutLevels ) ) == ( XieLut ) NULL )
 
161
                {
 
162
                        reps = 0;
 
163
                }
 
164
                else if ( ( PhotofloTestLut2 = GetXIELut( xp, p, lut2, lutSize,
 
165
                        lutLevels ) ) == ( XieLut ) NULL )
 
166
                {
 
167
                        reps = 0;
 
168
                }
 
169
        }
 
170
 
 
171
        if ( reps )
 
172
        {
 
173
 
 
174
                XieFloImportLUT(&flograph[0], PhotofloTestLut1 );
 
175
 
 
176
                merge = False;
 
177
                start[ 0 ] = 0;
 
178
                start[ 1 ] = 0;
 
179
                start[ 2 ] = 0;
 
180
 
 
181
                XieFloExportLUT(&flograph[1],
 
182
                        1,              /* source phototag number */
 
183
                        PhotofloTestLut2,
 
184
                        merge,
 
185
                        start
 
186
                );
 
187
                flo = XieCreatePhotoflo( xp->d, flograph, flo_elements );
 
188
        }
 
189
 
 
190
        if ( !reps )
 
191
                FreeQueryPhotofloStuff( xp, p );
 
192
 
 
193
        if ( lut1 )
 
194
                free( lut1 );
 
195
        if ( lut2 )
 
196
                free( lut2 );
 
197
 
 
198
        return reps;
 
199
}
 
200
 
 
201
void 
 
202
DoQueryTechniques(XParms xp, Parms p, int reps)
 
203
{
 
204
        XieTechniqueGroup       techGroup;
 
205
        XieTechnique            *techVector;
 
206
        int                     j, i, numTech;
 
207
 
 
208
        techGroup = ( ( QueryParms * ) p->ts )->techGroup;
 
209
 
 
210
        for ( i = 0; i < reps; i++ )
 
211
        {
 
212
                if ( !XieQueryTechniques( xp->d, techGroup, &numTech, 
 
213
                                &techVector ) )
 
214
                {
 
215
                        fprintf( stderr, "XieQueryTechniques: failed\n" );
 
216
                        break;
 
217
                }
 
218
 
 
219
                /* this bites */
 
220
 
 
221
                for ( j = 0; j < numTech; j++ )
 
222
                {
 
223
                        if ( techVector[ j ].name )
 
224
                                XFree( techVector[ j ].name );
 
225
                }
 
226
                if ( techVector )
 
227
                {
 
228
                        XFree( techVector );
 
229
                        techVector = ( XieTechnique * ) NULL;
 
230
                }
 
231
        }
 
232
}
 
233
 
 
234
void 
 
235
DoQueryColorList(XParms xp, Parms p, int reps)
 
236
{
 
237
        int     i;
 
238
        Colormap cmap;
 
239
        unsigned int ncolors;
 
240
        unsigned long *colors;
 
241
 
 
242
        for ( i = 0; i < reps; i++ )
 
243
        {
 
244
                colors = ( unsigned long * ) NULL;
 
245
                if ( !XieQueryColorList( xp->d, XIEColorList, &cmap, 
 
246
                        &ncolors, &colors ) )
 
247
                {
 
248
                        fprintf( stderr, "XieQueryColorList failed\n" );
 
249
                        break;
 
250
                }
 
251
                
 
252
                /* for alpha, the colorlist is empty. This will change
 
253
                   later */
 
254
 
 
255
                if ( cmap != ( Colormap ) 0 )
 
256
                {
 
257
                        fprintf( stderr, "XieQueryColorList returned non-zero colormap\n" );
 
258
                        break;
 
259
                }
 
260
                if ( ncolors != 0 )
 
261
                {
 
262
                        fprintf( stderr, "XieQueryColorList returned non-zero ncolors\n" );
 
263
                        break;
 
264
                }
 
265
                if ( colors != ( unsigned long * ) NULL )
 
266
                {
 
267
                        fprintf( stderr, "XieQueryColorList returned non-NULL colorlist\n" );
 
268
                        break;
 
269
                }
 
270
        }
 
271
}
 
272
 
 
273
void 
 
274
DoQueryPhotomap(XParms xp, Parms p, int reps)
 
275
{
 
276
        int     i;
 
277
        XieLTriplet     width;
 
278
        XieLTriplet     height;
 
279
        XieLTriplet     levels;
 
280
        XieDataType     data_type;
 
281
        XieDataClass    cclass;
 
282
        Bool    pop, error;
 
283
        XieDecodeTechnique decode;
 
284
        XIEimage *image;
 
285
 
 
286
        image = p->finfo.image1;
 
287
        if ( !image )
 
288
                return;
 
289
 
 
290
        error = False;
 
291
        for ( i = 0; i < reps && error == False; i++ )
 
292
        {
 
293
                if ( !XieQueryPhotomap( xp->d, XIEPhotomap, &pop, &data_type,
 
294
                        &cclass, &decode, width, height, levels ) )
 
295
                {
 
296
                        fprintf( stderr, "XieQueryPhotomap failed\n" );
 
297
                        fflush( stderr );
 
298
                        error = True;
 
299
                }
 
300
                if ( levels[ 0 ] != image->levels[ 0 ] )
 
301
                {
 
302
                        fprintf( stderr, "XieQueryPhotomap levels return invalid should be 0x%lx got 0x%lx\n", image->levels[ 0 ], levels[ 0 ] );
 
303
                        fflush( stderr );
 
304
                        error = True;
 
305
                }
 
306
                if ( width[ 0 ] != image->width[ 0 ] )
 
307
                {
 
308
                        fprintf( stderr, "XieQueryPhotomap width return invalid should be 0x%x got 0x%lx\n", image->width[ 0 ], width[ 0 ] );
 
309
                        fflush( stderr );
 
310
                        error = True;
 
311
                }
 
312
                if ( height[ 0 ] != image->height[ 0 ] )
 
313
                {
 
314
                        fprintf( stderr, "XieQueryPhotomap height return invalid should be 0x%x got 0x%lx\n", image->height[ 0 ], height[ 0 ] );
 
315
                        fflush( stderr );
 
316
                        error = True;
 
317
                }
 
318
        }
 
319
}
 
320
 
 
321
void 
 
322
DoQueryPhotoflo(XParms xp, Parms p, int reps)
 
323
{
 
324
        int     i;
 
325
        XiePhotofloState state;
 
326
        XiePhototag *expected, *avail;
 
327
        unsigned int nexpected, navail;
 
328
 
 
329
        for ( i = 0; i < reps; i++ )
 
330
        {
 
331
                if ( !XieQueryPhotoflo( xp->d, 0, flo, &state, &expected,
 
332
                        &nexpected, &avail, &navail ) )
 
333
                {
 
334
                        fprintf( stderr, "XieQueryPhotoflo failed\n" );
 
335
                }
 
336
                if ( expected )
 
337
                {
 
338
                        XFree( expected );
 
339
                }
 
340
                if ( avail )
 
341
                {
 
342
                        XFree( avail );
 
343
                }
 
344
        }
 
345
}
 
346
 
 
347
void
 
348
EndQueryTechniques(XParms xp, Parms p)
 
349
{
 
350
}
 
351
 
 
352
void
 
353
EndQueryColorList(XParms xp, Parms p)
 
354
{
 
355
        FreeQueryColorListStuff( xp, p );
 
356
}
 
357
 
 
358
void
 
359
FreeQueryColorListStuff(XParms xp, Parms p)
 
360
{
 
361
        if ( XIEColorList )
 
362
        {
 
363
                XieDestroyColorList( xp->d, XIEColorList );
 
364
                XIEColorList = ( XieColorList ) NULL;
 
365
        }
 
366
}
 
367
 
 
368
void
 
369
EndQueryPhotomap(XParms xp, Parms p)
 
370
{
 
371
        FreeQueryPhotomapStuff( xp, p );
 
372
}
 
373
 
 
374
void
 
375
FreeQueryPhotomapStuff(XParms xp, Parms p)
 
376
{
 
377
        if ( XIEPhotomap && IsPhotomapInCache( XIEPhotomap ) == False )
 
378
        {
 
379
                XieDestroyPhotomap( xp->d, XIEPhotomap );
 
380
                XIEPhotomap = ( XiePhotomap ) NULL;
 
381
        }
 
382
}
 
383
 
 
384
void
 
385
EndQueryPhotoflo(XParms xp, Parms p)
 
386
{
 
387
        FreeQueryPhotofloStuff( xp, p );
 
388
}
 
389
 
 
390
void
 
391
FreeQueryPhotofloStuff(XParms xp, Parms p)
 
392
{
 
393
        if ( PhotofloTestLut1 )
 
394
        {
 
395
                XieDestroyLUT( xp->d, PhotofloTestLut1 );
 
396
                PhotofloTestLut1 = ( XieLut ) NULL;
 
397
        }
 
398
 
 
399
        if ( PhotofloTestLut2 )
 
400
        {
 
401
                XieDestroyLUT( xp->d, PhotofloTestLut2 );
 
402
                PhotofloTestLut2 = ( XieLut ) NULL;
 
403
        }
 
404
 
 
405
        if ( flograph )
 
406
        {
 
407
                XieFreePhotofloGraph(flograph,flo_elements);
 
408
                flograph = ( XiePhotoElement * ) NULL;
 
409
        }
 
410
 
 
411
        if ( flo )
 
412
        {
 
413
                XieDestroyPhotoflo( xp->d, flo );
 
414
                flo = ( XiePhotoflo ) NULL;
 
415
        }
 
416
}
 
417
 
 
418