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

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/XIE/dixie/process/pcnst.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: pcnst.c,v 1.4 2001/02/09 02:04:20 xorgcvs Exp $ */
 
2
/**** module pcnst.c ****/
 
3
/******************************************************************************
 
4
 
 
5
Copyright 1993, 1994, 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
                                NOTICE
 
29
                              
 
30
This software is being provided by AGE Logic, Inc. under the
 
31
following license.  By obtaining, using and/or copying this software,
 
32
you agree that you have read, understood, and will comply with these
 
33
terms and conditions:
 
34
 
 
35
     Permission to use, copy, modify, distribute and sell this
 
36
     software and its documentation for any purpose and without
 
37
     fee or royalty and to grant others any or all rights granted
 
38
     herein is hereby granted, provided that you agree to comply
 
39
     with the following copyright notice and statements, including
 
40
     the disclaimer, and that the same appears on all copies and
 
41
     derivative works of the software and documentation you make.
 
42
     
 
43
     "Copyright 1993, 1994 by AGE Logic, Inc."
 
44
     
 
45
     THIS SOFTWARE IS PROVIDED "AS IS".  AGE LOGIC MAKES NO
 
46
     REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.  By way of
 
47
     example, but not limitation, AGE LOGIC MAKE NO
 
48
     REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS
 
49
     FOR ANY PARTICULAR PURPOSE OR THAT THE SOFTWARE DOES NOT
 
50
     INFRINGE THIRD-PARTY PROPRIETARY RIGHTS.  AGE LOGIC 
 
51
     SHALL BEAR NO LIABILITY FOR ANY USE OF THIS SOFTWARE.  IN NO
 
52
     EVENT SHALL EITHER PARTY BE LIABLE FOR ANY INDIRECT,
 
53
     INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS
 
54
     OF PROFITS, REVENUE, DATA OR USE, INCURRED BY EITHER PARTY OR
 
55
     ANY THIRD PARTY, WHETHER IN AN ACTION IN CONTRACT OR TORT OR
 
56
     BASED ON A WARRANTY, EVEN IF AGE LOGIC LICENSEES
 
57
     HEREUNDER HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
 
58
     DAMAGES.
 
59
    
 
60
     The name of AGE Logic, Inc. may not be used in
 
61
     advertising or publicity pertaining to this software without
 
62
     specific, written prior permission from AGE Logic.
 
63
 
 
64
     Title to this software shall at all times remain with AGE
 
65
     Logic, Inc.
 
66
*****************************************************************************
 
67
  
 
68
        pcnst..c -- DIXIE routines for managing the Constrain element
 
69
  
 
70
        Dean Verheiden -- AGE Logic, Inc. May 1993
 
71
  
 
72
*****************************************************************************/
 
73
/* $XFree86: xc/programs/Xserver/XIE/dixie/process/pcnst.c,v 3.6 2001/12/14 19:58:04 dawes Exp $ */
 
74
 
 
75
#define _XIEC_PCNST
 
76
 
 
77
/*
 
78
 *  Include files
 
79
 */
 
80
 
 
81
  /*
 
82
   *  Core X Includes
 
83
   */
 
84
#define NEED_EVENTS
 
85
#include <X.h>
 
86
#include <Xproto.h>
 
87
  /*
 
88
   *  XIE Includes
 
89
   */
 
90
#include <dixie_p.h>
 
91
  /*
 
92
   *  Server XIE Includes
 
93
   */
 
94
#include <corex.h>
 
95
#include <error.h>
 
96
#include <macro.h>
 
97
#include <element.h>
 
98
#include <technq.h>
 
99
#include <difloat.h>
 
100
#include <memory.h>
 
101
 
 
102
/*
 
103
 *  routines internal to this module
 
104
 */
 
105
static Bool PrepPConstrain(floDefPtr flo, peDefPtr ped);
 
106
 
 
107
/*
 
108
 * dixie element entry points
 
109
 */
 
110
static diElemVecRec pConstrainVec = {
 
111
  PrepPConstrain                /* prepare for analysis and execution   */
 
112
  };
 
113
 
 
114
/*------------------------------------------------------------------------
 
115
-------------------- routine: make a constrain element ------------------
 
116
------------------------------------------------------------------------*/
 
117
peDefPtr MakeConstrain(floDefPtr flo, xieTypPhototag tag, xieFlo *pe)
 
118
{
 
119
  peDefPtr ped;
 
120
  ELEMENT(xieFloConstrain);
 
121
  ELEMENT_AT_LEAST_SIZE(xieFloConstrain);
 
122
  ELEMENT_NEEDS_1_INPUT(src);
 
123
  
 
124
  if(!(ped = MakePEDef(1, (CARD32)stuff->elemLength<<2, 0)))
 
125
    FloAllocError(flo,tag,xieElemConstrain, return(NULL)) ;
 
126
 
 
127
  ped->diVec         = &pConstrainVec;
 
128
  ped->phototag      = tag;
 
129
  ped->flags.process = TRUE;
 
130
  raw = (xieFloConstrain *)ped->elemRaw;
 
131
  /*
 
132
   * copy the client element parameters (swap if necessary)
 
133
   */
 
134
  if( flo->reqClient->swapped ) {
 
135
    raw->elemType   = stuff->elemType;
 
136
    raw->elemLength = stuff->elemLength;
 
137
    cpswaps(stuff->src, raw->src);
 
138
    cpswapl(stuff->levels0,  raw->levels0);
 
139
    cpswapl(stuff->levels1,  raw->levels1);
 
140
    cpswapl(stuff->levels2,  raw->levels2);
 
141
    cpswaps(stuff->lenParams, raw->lenParams);
 
142
    cpswaps(stuff->constrain, raw->constrain);
 
143
  }
 
144
  else
 
145
    memcpy((char *)raw, (char *)stuff, sizeof(xieFloConstrain));
 
146
  /*
 
147
   * copy technique data (if any)
 
148
   */
 
149
  if(!(ped->techVec = FindTechnique(xieValConstrain, raw->constrain)) ||
 
150
     !(ped->techVec->copyfnc(flo, ped, &stuff[1], &raw[1], raw->lenParams, 0)))
 
151
    TechniqueError(flo,ped,xieValConstrain,raw->constrain,raw->lenParams,
 
152
                   return(ped));
 
153
 
 
154
 /*
 
155
   * assign phototag to inFlo
 
156
   */
 
157
  ped->inFloLst[SRCtag].srcTag = raw->src;
 
158
 
 
159
 
 
160
  return(ped);
 
161
}                               /* end MakePConstrain */
 
162
 
 
163
/*------------------------------------------------------------------------
 
164
---------------- routine: copy routine for no param techniques -------------
 
165
------------------------------------------------------------------------*/
 
166
 
 
167
Bool CopyPConstrainStandard(TECHNQ_COPY_ARGS)
 
168
{
 
169
  return(tsize == 0);
 
170
}
 
171
 
 
172
/*------------------------------------------------------------------------
 
173
---------------- routine: copy routine for Clip-Scale technique  ---------
 
174
------------------------------------------------------------------------*/
 
175
 
 
176
#undef  sparms
 
177
#define sparms ((xieTecClipScale *)sParms)
 
178
#undef  rparms
 
179
#define rparms ((xieTecClipScale *)rParms)
 
180
 
 
181
Bool CopyPConstrainClipScale(TECHNQ_COPY_ARGS)
 
182
{
 
183
     pCnstDefPtr pvt;
 
184
 
 
185
     VALIDATE_TECHNIQUE_SIZE(ped->techVec, tsize, FALSE);
 
186
 
 
187
     if (!(ped->techPvt = (pointer )XieMalloc(sizeof(pCnstDefRec))))
 
188
             FloAllocError(flo, ped->phototag,xieElemConstrain, return(TRUE));
 
189
 
 
190
     pvt = (pCnstDefPtr)ped->techPvt;
 
191
 
 
192
     if( flo->reqClient->swapped ) {
 
193
             pvt->input_low[0] = ConvertFromIEEE(lswapl(sparms->inputLow0));
 
194
             pvt->input_low[1] = ConvertFromIEEE(lswapl(sparms->inputLow1));
 
195
             pvt->input_low[2] = ConvertFromIEEE(lswapl(sparms->inputLow2));
 
196
             pvt->input_high[0] = ConvertFromIEEE(lswapl(sparms->inputHigh0));
 
197
             pvt->input_high[1] = ConvertFromIEEE(lswapl(sparms->inputHigh1));
 
198
             pvt->input_high[2] = ConvertFromIEEE(lswapl(sparms->inputHigh2));
 
199
             cpswapl(sparms->outputLow0,  pvt->output_low[0]);
 
200
             cpswapl(sparms->outputLow1,  pvt->output_low[1]);
 
201
             cpswapl(sparms->outputLow2,  pvt->output_low[2]);
 
202
             cpswapl(sparms->outputHigh0, pvt->output_high[0]);
 
203
             cpswapl(sparms->outputHigh1, pvt->output_high[1]);
 
204
             cpswapl(sparms->outputHigh2, pvt->output_high[2]);
 
205
      } else {
 
206
             pvt->input_low[0] = ConvertFromIEEE(sparms->inputLow0);
 
207
             pvt->input_low[1] = ConvertFromIEEE(sparms->inputLow1);
 
208
             pvt->input_low[2] = ConvertFromIEEE(sparms->inputLow2);
 
209
             pvt->input_high[0] = ConvertFromIEEE(sparms->inputHigh0);
 
210
             pvt->input_high[1] = ConvertFromIEEE(sparms->inputHigh1);
 
211
             pvt->input_high[2] = ConvertFromIEEE(sparms->inputHigh2);
 
212
             pvt->output_low[0] = sparms->outputLow0;
 
213
             pvt->output_low[1] = sparms->outputLow1;
 
214
             pvt->output_low[2] = sparms->outputLow2;
 
215
             pvt->output_high[0] = sparms->outputHigh0;
 
216
             pvt->output_high[1] = sparms->outputHigh1;
 
217
             pvt->output_high[2] = sparms->outputHigh2;
 
218
      }
 
219
 
 
220
     return (TRUE);
 
221
}
 
222
/*------------------------------------------------------------------------
 
223
---------------- routine: prep routine for no param techniques -------------
 
224
------------------------------------------------------------------------*/
 
225
Bool PrepPConstrainStandard(
 
226
     floDefPtr  flo,
 
227
     peDefPtr   ped,
 
228
     pointer raw,
 
229
     pointer tec)
 
230
{
 
231
  return(TRUE);
 
232
}
 
233
/*------------------------------------------------------------------------
 
234
---------------- routine: prep routine for Clip Scale technique ----------
 
235
------------------------------------------------------------------------*/
 
236
Bool PrepPConstrainClipScale(
 
237
     floDefPtr  flo,
 
238
     peDefPtr   ped,
 
239
     xieTecClipScale *raw,
 
240
     xieTecClipScale *tec)
 
241
{
 
242
  pCnstDefPtr pvt = (pCnstDefPtr)ped->techPvt;
 
243
 
 
244
  if (pvt->input_low[0] == pvt->input_high[0] ||
 
245
      pvt->output_low[0] > ped->outFlo.format[0].levels - 1 ||
 
246
      pvt->output_high[0] > ped->outFlo.format[0].levels - 1)
 
247
                return(FALSE);
 
248
  if (ped->outFlo.bands > 1) {
 
249
        if (  pvt->input_low[1] == pvt->input_high[1] ||
 
250
              pvt->output_low[1] > ped->outFlo.format[1].levels - 1 ||
 
251
              pvt->output_high[1] > ped->outFlo.format[1].levels - 1 ||
 
252
              pvt->input_low[2] == pvt->input_high[2] ||
 
253
              pvt->output_low[2] > ped->outFlo.format[2].levels - 1 ||
 
254
              pvt->output_high[2] > ped->outFlo.format[2].levels - 1)
 
255
                return(FALSE);
 
256
  }
 
257
 
 
258
  return(TRUE);
 
259
}
 
260
 
 
261
/*------------------------------------------------------------------------
 
262
---------------- routine: prepare for analysis and execution -------------
 
263
------------------------------------------------------------------------*/
 
264
 
 
265
static Bool PrepPConstrain(
 
266
     floDefPtr  flo,
 
267
     peDefPtr   ped)
 
268
{
 
269
  inFloPtr inf = &ped->inFloLst[SRCtag];
 
270
  outFloPtr src = &inf->srcDef->outFlo;
 
271
  outFloPtr dst = &ped->outFlo;
 
272
  xieFloConstrain *raw = (xieFloConstrain *)ped->elemRaw;
 
273
  int b;
 
274
 
 
275
  /* grab a copy of the src attributes and propagate them to our input */
 
276
  dst->bands = inf->bands = src->bands;
 
277
  for(b = 0; b < src->bands; b++) {
 
278
 
 
279
        /* This should be impossible */
 
280
        if (IsntCanonic(src->format[b].class))
 
281
                ImplementationError(flo, ped, return(FALSE));
 
282
 
 
283
        inf->format[b] = src->format[b];
 
284
 
 
285
        /* Copy outFlo values that are unchanged by constrain */
 
286
        dst->format[b].band             = b;
 
287
        dst->format[b].interleaved      = src->format[b].interleaved;
 
288
        dst->format[b].width            = src->format[b].width;
 
289
        dst->format[b].height           = src->format[b].height;
 
290
  }
 
291
  /* Pull in levels information from the element description */ 
 
292
  if ((dst->format[0].levels = raw->levels0) > MAX_LEVELS(src->bands))
 
293
        ValueError(flo,ped,raw->levels0,return(FALSE));
 
294
  if (dst->bands > 1) {
 
295
        if ((dst->format[1].levels = raw->levels1) > MAX_LEVELS(src->bands))
 
296
                ValueError(flo,ped,raw->levels1,return(FALSE));
 
297
        if ((dst->format[2].levels = raw->levels2) > MAX_LEVELS(src->bands))
 
298
                ValueError(flo,ped,raw->levels2,return(FALSE));
 
299
  }
 
300
  /* Set depth, class, stride, and pitch */
 
301
  if(!UpdateFormatfromLevels(ped))
 
302
    MatchError(flo,ped, return(FALSE));
 
303
 
 
304
  /* Take care of any technique parameters */
 
305
  if (!(ped->techVec->prepfnc(flo, ped, raw, &raw[1])))
 
306
        TechniqueError(flo,ped,xieValConstrain,raw->constrain,raw->lenParams,
 
307
                       return(FALSE));
 
308
  return (TRUE);
 
309
}       
 
310
 
 
311
/* end module pcnst.c */