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

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/PEX5/ddpex/mi/shared/miClrApLUT.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: miClrApLUT.c,v 1.4 2001/02/09 02:04:12 xorgcvs Exp $ */
 
2
/*
 
3
 
 
4
Copyright 1990, 1991, 1998  The Open Group
 
5
 
 
6
Permission to use, copy, modify, distribute, and sell this software and its
 
7
documentation for any purpose is hereby granted without fee, provided that
 
8
the above copyright notice appear in all copies and that both that
 
9
copyright notice and this permission notice appear in supporting
 
10
documentation.
 
11
 
 
12
The above copyright notice and this permission notice shall be included
 
13
in all copies or substantial portions of the Software.
 
14
 
 
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 
16
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
17
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 
18
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
 
19
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 
20
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 
21
OTHER DEALINGS IN THE SOFTWARE.
 
22
 
 
23
Except as contained in this notice, the name of The Open Group shall
 
24
not be used in advertising or otherwise to promote the sale, use or
 
25
other dealings in this Software without prior written authorization
 
26
from The Open Group.
 
27
 
 
28
 
 
29
Copyright 1990, 1991 by Sun Microsystems, Inc. 
 
30
All Rights Reserved
 
31
 
 
32
Permission to use, copy, modify, and distribute this software and its
 
33
documentation for any purpose and without fee is hereby granted,
 
34
provided that the above copyright notice appear in all copies and that
 
35
both that copyright notice and this permission notice appear in
 
36
supporting documentation, and that the name of Sun Microsystems
 
37
not be used in advertising or publicity pertaining to distribution
 
38
of the software without specific, written prior permission.
 
39
 
 
40
SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
41
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
 
42
SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 
43
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 
44
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 
45
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 
46
SOFTWARE.
 
47
 
 
48
*/
 
49
/* $XFree86: xc/programs/Xserver/PEX5/ddpex/mi/shared/miClrApLUT.c,v 1.9 2001/12/14 19:57:37 dawes Exp $ */
 
50
 
 
51
#include "miLUT.h"
 
52
#include "miWks.h"
 
53
#include "miInfo.h"
 
54
#include "PEXErr.h"
 
55
#include "PEXprotost.h"
 
56
#include "pexos.h"
 
57
 
 
58
 
 
59
/*  Level 4 Shared Resources  */
 
60
/* Lookup Table Procedures */
 
61
 
 
62
/* definitions used by miLUTProcs.ci */
 
63
#define LUT_TYPE        PEXColourApproxLUT
 
64
 
 
65
/* devPriv data structure */
 
66
#define DD_LUT_ENTRY_STR        ddColourApproxEntry 
 
67
/* table entry data structure */
 
68
#define MI_LUT_ENTRY_STR        miColourApproxEntry
 
69
/* pex data */
 
70
#define PEX_LUT_ENTRY_STR       pexColourApproxEntry
 
71
 
 
72
#define LUT_REND_DYN_BIT        PEXDynColourApproxContents
 
73
 
 
74
#define LUT_START_INDEX          0
 
75
#define LUT_DEFAULT_INDEX        0
 
76
#define LUT_0_DEFINABLE_ENTRIES  6
 
77
#define LUT_0_NUM_PREDEFINED     0
 
78
#define LUT_0_PREDEFINED_MIN     0
 
79
#define LUT_0_PREDEFINED_MAX     0
 
80
 
 
81
#define LUT_TABLE_START(pheader)        (pheader)->plut.colourApprox
 
82
 
 
83
#define DYNAMIC         COLOUR_APPROX_TABLE_DYNAMIC
 
84
 
 
85
/* predefined entries table: change this to work with your devPriv data */
 
86
/* there are no predefined entries, but define 1 entry for default */
 
87
static  DD_LUT_ENTRY_STR        pdeColourApproxEntry[1];
 
88
#define LUT_PDE_ENTRIES         pdeColourApproxEntry[0]
 
89
#define LUT_SET_PDE_ENTRY(pentry, pdeentry)     \
 
90
        (pentry)->entry = *(pdeentry)
 
91
 
 
92
/* predefined entry 0 is set to the default values 
 
93
 * change the XXX_DEFAULT_YYY macros below to use something else
 
94
 * if you don't want the default values defined in the pde table
 
95
 */
 
96
#define PDE_DEFAULT_ENTRY_NUM   0
 
97
#define LUT_DEFAULT_VALUES      pdeColourApproxEntry[PDE_DEFAULT_ENTRY_NUM]
 
98
#define LUT_SET_DEFAULT_VALUES(pentry)          \
 
99
        (pentry)->entry = LUT_DEFAULT_VALUES
 
100
 
 
101
/* which procedure definitions in miLUTProcs.h to use and their names
 
102
 * take out USE flags if you're defining those procs in here
 
103
 * but leave the name definitions
 
104
 */
 
105
 
 
106
#define LUT_USE_FREE
 
107
#define LUT_USE_INQ_PREDEF
 
108
#define LUT_USE_INQ_ENTRIES
 
109
#define LUT_USE_COPY
 
110
#define LUT_USE_INQ_INFO
 
111
#define LUT_USE_INQ_IND
 
112
#define LUT_USE_INQ_ENTRY
 
113
#define LUT_USE_SET_ENTRIES
 
114
#define LUT_USE_DEL_ENTRIES
 
115
#define LUT_USE_INQ_ENTRY_ADDRESS
 
116
#define LUT_USE_CREATE
 
117
#define LUT_USE_MOD_CALL_BACK
 
118
 
 
119
/* these three are redefined in miLUTProcs.h
 
120
#define LUT_FREE        ColourApproxLUT_free
 
121
#define LUT_INQ_PREDEF  ColourApproxLUT_inq_predef
 
122
#define LUT_INQ_ENTRIES ColourApproxLUT_inq_entries
 
123
*/
 
124
#define LUT_COPY        ColourApproxLUT_copy
 
125
#define LUT_INQ_INFO    ColourApproxLUT_inq_info
 
126
#define LUT_INQ_IND     ColourApproxLUT_inq_ind
 
127
#define LUT_INQ_ENTRY   ColourApproxLUT_inq_entry
 
128
#define LUT_SET_ENTRIES ColourApproxLUT_set_entries
 
129
#define LUT_DEL_ENTRIES ColourApproxLUT_del_entries
 
130
#define LUT_INQ_ENTRY_ADDRESS   ColourApproxLUT_inq_entry_address
 
131
#define LUT_CREATE      ColourApproxLUT_create
 
132
#define LUT_ENTRY_CHECK ColourApproxLUT_entry_check
 
133
#define LUT_COPY_PEX_MI ColourApproxLUT_copy_pex_to_mi
 
134
#define LUT_COPY_MI_PEX ColourApproxLUT_copy_mi_to_pex
 
135
#define LUT_MOD_CALL_BACK       ColourApproxLUT_mod_call_back
 
136
 
 
137
/* copy from an mi entry to a pex entry and increment ppbuf */
 
138
ddpex43rtn
 
139
LUT_COPY_MI_PEX( pheader, valueType, pentry, ppbuf )
 
140
        miLUTHeader             *pheader;
 
141
        ddUSHORT                valueType;
 
142
        MI_LUT_ENTRY_STR        *pentry;
 
143
        ddPointer               *ppbuf;
 
144
{
 
145
        if (pentry == NULL)
 
146
                mibcopy(&(LUT_DEFAULT_VALUES), *ppbuf, sizeof(PEX_LUT_ENTRY_STR));
 
147
        else if (pentry->entry_info.status == MILUT_UNDEFINED)
 
148
                mibcopy(&(LUT_DEFAULT_VALUES), *ppbuf, sizeof(PEX_LUT_ENTRY_STR));
 
149
        else
 
150
                mibcopy(&pentry->entry, *ppbuf, sizeof(PEX_LUT_ENTRY_STR));
 
151
 
 
152
        *ppbuf += sizeof(PEX_LUT_ENTRY_STR);
 
153
 
 
154
        return(Success);
 
155
}
 
156
 
 
157
/* copy from a pex entry to an mi entry and increment ppsrc */
 
158
ddpex43rtn
 
159
LUT_COPY_PEX_MI( pheader, ppsrc, pentry )
 
160
        miLUTHeader             *pheader;
 
161
        ddPointer               *ppsrc;
 
162
        MI_LUT_ENTRY_STR        *pentry;
 
163
{
 
164
        mibcopy(*ppsrc, &(pentry->entry), sizeof(PEX_LUT_ENTRY_STR));
 
165
        *ppsrc += sizeof(PEX_LUT_ENTRY_STR);
 
166
 
 
167
        return(Success);
 
168
}
 
169
 
 
170
/* check for bad values and increment ppPexEntry */
 
171
 
 
172
ddpex43rtn
 
173
LUT_ENTRY_CHECK (pheader, ppPexEntry)
 
174
        miLUTHeader             *pheader;
 
175
        PEX_LUT_ENTRY_STR       **ppPexEntry;
 
176
{
 
177
    extern miEnumType   miColourApproxTypeET[][SI_CLR_APPROX_TYPE_NUM];
 
178
    extern miEnumType   miColourApproxModelET[][SI_CLR_APPROX_MODEL_NUM];
 
179
 
 
180
        if (((*ppPexEntry)->approxType < miColourApproxTypeET[pheader->drawType][0].index) ||
 
181
            ((*ppPexEntry)->approxType > miColourApproxTypeET[pheader->drawType][SI_CLR_APPROX_TYPE_NUM - 1].index))
 
182
                return(BadValue);
 
183
        if (((*ppPexEntry)->approxModel < miColourApproxModelET[pheader->drawType][0].index) ||
 
184
            ((*ppPexEntry)->approxModel > miColourApproxModelET[pheader->drawType][SI_CLR_APPROX_MODEL_NUM - 1].index))
 
185
                return(BadValue);
 
186
        if (((*ppPexEntry)->dither != PEXOff) && ((*ppPexEntry)->dither != PEXOn))
 
187
                return(BadValue);
 
188
 
 
189
    (*ppPexEntry)++;
 
190
    return(Success);
 
191
}
 
192
 
 
193
void
 
194
ColourApproxLUT_init_pde()
 
195
{
 
196
    /* Having default values for this makes absolutely no sense.
 
197
     * There is no way for this to know what colors are defined in
 
198
     * the coloramp, and therefor no way to know how to map to them.
 
199
     * This is provided only because something has to be done, but
 
200
     * the likelyhood of this turning out correct colors is small.
 
201
     * The client side MUST set at least one entry in this table
 
202
     * for correct functionality.
 
203
     * These are the sample values in the protocol spec.  
 
204
     * They assume a 6x6x6 color cube beginning at location 16.
 
205
     */
 
206
    pdeColourApproxEntry [0].approxType = PEXColourSpace;
 
207
    pdeColourApproxEntry [0].approxModel = PEXColourApproxRGB;
 
208
    pdeColourApproxEntry [0].max1 = 5;
 
209
    pdeColourApproxEntry [0].max2 = 5;
 
210
    pdeColourApproxEntry [0].max3 = 5;
 
211
    pdeColourApproxEntry [0].dither = PEXOff;
 
212
    pdeColourApproxEntry [0].mult1 = 1;
 
213
    pdeColourApproxEntry [0].mult2 = 6;
 
214
    pdeColourApproxEntry [0].mult3 = 36;
 
215
    pdeColourApproxEntry [0].weight1 = 1.0;
 
216
    pdeColourApproxEntry [0].weight2 = 1.0;
 
217
    pdeColourApproxEntry [0].weight3 = 1.0;
 
218
    pdeColourApproxEntry [0].basePixel = 16;
 
219
}
 
220
 
 
221
#include "miLUTProcs.ci"