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

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/XIE/dixie/process/pdither.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: pdither.c,v 1.4 2001/02/09 02:04:22 xorgcvs Exp $ */
 
2
/**** module pdither.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
        pdither.c -- DIXIE routines for managing the Dither element
 
69
  
 
70
        Larry Hare -- AGE Logic, Inc. May 1993
 
71
  
 
72
*****************************************************************************/
 
73
/* $XFree86: xc/programs/Xserver/XIE/dixie/process/pdither.c,v 3.5 2001/12/14 19:58:05 dawes Exp $ */
 
74
 
 
75
#define _XIEC_PDITHER
 
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
 
 
101
/*
 
102
 *  routines internal to this module
 
103
 */
 
104
static Bool PrepPDither(floDefPtr flo, peDefPtr ped);
 
105
static Bool PrepPDitherStandard(floDefPtr flo, peDefPtr ped, pointer raw, pointer tec);
 
106
 
 
107
/*
 
108
 * dixie element entry points
 
109
 */
 
110
static diElemVecRec pDitherVec = {
 
111
  PrepPDither           /* prepare for analysis and execution   */
 
112
  };
 
113
 
 
114
/*------------------------------------------------------------------------
 
115
-------------------- routine: make a dither element ------------------
 
116
------------------------------------------------------------------------*/
 
117
peDefPtr MakeDither(floDefPtr flo, xieTypPhototag tag, xieFlo *pe)
 
118
{
 
119
  peDefPtr ped;
 
120
  ELEMENT(xieFloDither);
 
121
  ELEMENT_AT_LEAST_SIZE(xieFloDither);
 
122
  ELEMENT_NEEDS_1_INPUT(src);
 
123
  
 
124
  if(!(ped = MakePEDef(1, (CARD32)stuff->elemLength<<2, 0)))
 
125
    FloAllocError(flo,tag,xieElemDither, return(NULL)) ;
 
126
 
 
127
  ped->diVec         = &pDitherVec;
 
128
  ped->phototag      = tag;
 
129
  ped->flags.process = TRUE;
 
130
  raw = (xieFloDither *)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
    raw->bandMask = stuff->bandMask;
 
139
    cpswapl(stuff->levels0,  raw->levels0);
 
140
    cpswapl(stuff->levels1,  raw->levels1);
 
141
    cpswapl(stuff->levels2,  raw->levels2);
 
142
    cpswaps(stuff->lenParams, raw->lenParams);
 
143
    cpswaps(stuff->dither, raw->dither);
 
144
  }
 
145
  else
 
146
    memcpy((char *)raw, (char *)stuff, sizeof(xieFloDither));
 
147
  /*
 
148
   * copy technique data (if any)
 
149
   */
 
150
  if(!(ped->techVec = FindTechnique(xieValDither, raw->dither)) ||
 
151
     !(ped->techVec->copyfnc(flo, ped, &stuff[1], &raw[1], raw->lenParams,
 
152
                                          raw->dither == xieValDefault)))
 
153
    TechniqueError(flo,ped,xieValDither,raw->dither,raw->lenParams,
 
154
                   return(ped));
 
155
 
 
156
 /*
 
157
   * assign phototag to inFlo
 
158
   */
 
159
  ped->inFloLst[SRCtag].srcTag = raw->src;
 
160
 
 
161
 
 
162
  return(ped);
 
163
}                               /* end MakePDither */
 
164
 
 
165
/*------------------------------------------------------------------------
 
166
---------------- routine: copy routine for no Error Diffusion technique --
 
167
------------------------------------------------------------------------*/
 
168
 
 
169
Bool CopyPDitherErrorDiffusion(TECHNQ_COPY_ARGS)
 
170
{
 
171
  VALIDATE_TECHNIQUE_SIZE(ped->techVec, tsize, isDefault);
 
172
 
 
173
  return(tsize == 0);
 
174
}
 
175
 
 
176
/*------------------------------------------------------------------------
 
177
---------------- routine: copy routine for Ordered techniques  ---------
 
178
------------------------------------------------------------------------*/
 
179
 
 
180
#undef  sparms
 
181
#define sparms ((xieTecDitherOrdered *)sParms)
 
182
#undef  rparms
 
183
#define rparms ((xieTecDitherOrdered *)rParms)
 
184
 
 
185
Bool CopyPDitherOrdered(TECHNQ_COPY_ARGS)
 
186
{
 
187
     VALIDATE_TECHNIQUE_SIZE(ped->techVec, tsize, isDefault);
 
188
 
 
189
     if (tsize) 
 
190
        rparms->thresholdOrder = sparms->thresholdOrder;
 
191
     else
 
192
        rparms->thresholdOrder = 4;
 
193
 
 
194
     return(TRUE);
 
195
}
 
196
 
 
197
/*------------------------------------------------------------------------
 
198
---------------- routine: prep routine for no param techniques -------------
 
199
------------------------------------------------------------------------*/
 
200
static
 
201
Bool PrepPDitherStandard(
 
202
     floDefPtr  flo,
 
203
     peDefPtr   ped,
 
204
     pointer    raw,
 
205
     pointer    tec)
 
206
{
 
207
  return(TRUE);
 
208
}
 
209
 
 
210
/*------------------------------------------------------------------------
 
211
---------------- routine: prep routine for Error Diffusion techniques ----
 
212
------------------------------------------------------------------------*/
 
213
Bool PrepPDitherErrorDiffusion(
 
214
     floDefPtr  flo,
 
215
     peDefPtr   ped,
 
216
     xieFloDither *raw,
 
217
     pointer tec)
 
218
{
 
219
  return PrepPDitherStandard(flo, ped, (pointer) raw, tec);
 
220
}
 
221
 
 
222
/*------------------------------------------------------------------------
 
223
---------------- routine: prep routine for Ordered technique -------------
 
224
------------------------------------------------------------------------*/
 
225
Bool PrepPDitherOrdered(
 
226
     floDefPtr  flo,
 
227
     peDefPtr   ped,
 
228
     xieFloDither *raw,
 
229
     xieTecDitherOrdered *tec)
 
230
{
 
231
  return PrepPDitherStandard(flo, ped, (pointer) raw, (pointer) tec);
 
232
}
 
233
 
 
234
/*------------------------------------------------------------------------
 
235
---------------- routine: prepare for analysis and execution -------------
 
236
------------------------------------------------------------------------*/
 
237
 
 
238
static Bool PrepPDither(floDefPtr flo, peDefPtr ped)
 
239
{
 
240
  inFloPtr inf = &ped->inFloLst[SRCtag];
 
241
  outFloPtr src = &inf->srcDef->outFlo;
 
242
  outFloPtr dst = &ped->outFlo;
 
243
  xieFloDither *raw = (xieFloDither *)ped->elemRaw;
 
244
  CARD32 *levels = &(raw->levels0);
 
245
  int b;
 
246
 
 
247
  /* grab a copy of the src attributes and propagate them to our input */
 
248
  dst->bands = inf->bands = src->bands;
 
249
  for(b = 0; b < src->bands; b++) {
 
250
 
 
251
        dst->format[b] = inf->format[b] = src->format[b];
 
252
 
 
253
        if ((raw->bandMask & (1<<b)) == 0)
 
254
            continue;
 
255
 
 
256
        if (IsntConstrained(src->format[b].class) &&
 
257
            src->format[b].class == BIT_PIXEL)
 
258
                MatchError(flo, ped, return(FALSE));
 
259
 
 
260
        if ((dst->format[b].levels = *(levels+b)) > src->format[b].levels)
 
261
                ValueError(flo,ped,*(levels+b),return(FALSE));
 
262
  }
 
263
 
 
264
  /* Set depth, class, stride, and pitch */
 
265
  if (UpdateFormatfromLevels(ped) == FALSE)
 
266
        MatchError(flo,ped, return(FALSE));
 
267
 
 
268
  /* Take care of any technique parameters */
 
269
  if (!(ped->techVec->prepfnc(flo, ped, raw, &raw[1])))
 
270
        TechniqueError(flo,ped,xieValDither,raw->dither,raw->lenParams,
 
271
                       return(FALSE));
 
272
 
 
273
  return (TRUE);
 
274
}       
 
275
 
 
276
/* end module pdither.c */