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

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/hw/sun/sunMultiDepth.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: sunMultiDepth.c,v 1.4 2001/02/09 02:04:44 xorgcvs Exp $ */
 
2
/*
 
3
 
 
4
Copyright 1992, 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
 
 
30
/* $XFree86: xc/programs/Xserver/hw/sun/sunMultiDepth.c,v 1.6 2001/12/14 19:59:43 dawes Exp $ */
 
31
 
 
32
#include "X.h"
 
33
#include "Xmd.h"
 
34
#include "servermd.h"
 
35
#include "scrnintstr.h"
 
36
#include "pixmapstr.h"
 
37
#include "resource.h"
 
38
#include "colormap.h"
 
39
#include "colormapst.h"
 
40
#include "mi.h"
 
41
#include "mistruct.h"
 
42
#include "dix.h"
 
43
#include "gcstruct.h"
 
44
#include "mibstore.h"
 
45
 
 
46
#ifndef SINGLEDEPTH
 
47
 
 
48
static Bool
 
49
sunCfbCreateGC(pGC)
 
50
    GCPtr   pGC;
 
51
{
 
52
    if (pGC->depth == 1)
 
53
    {
 
54
        return mfbCreateGC (pGC);
 
55
    }
 
56
    else if (pGC->depth <= 8)
 
57
    {
 
58
        return cfbCreateGC (pGC);
 
59
    }
 
60
    else if (pGC->depth <= 16)
 
61
    {
 
62
        return cfb16CreateGC (pGC);
 
63
    }
 
64
    else if (pGC->depth <= 32)
 
65
    {
 
66
        return cfb32CreateGC (pGC);
 
67
    }
 
68
    return FALSE;
 
69
}
 
70
 
 
71
static void
 
72
sunCfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart)
 
73
    DrawablePtr         pDrawable;      /* drawable from which to get bits */
 
74
    int                 wMax;           /* largest value of all *pwidths */
 
75
    register DDXPointPtr ppt;           /* points to start copying from */
 
76
    int                 *pwidth;        /* list of number of bits to copy */
 
77
    int                 nspans;         /* number of scanlines to copy */
 
78
    char                *pdstStart;     /* where to put the bits */
 
79
{
 
80
    switch (pDrawable->bitsPerPixel) {
 
81
    case 1:
 
82
        mfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
 
83
        break;
 
84
    case 8:
 
85
        cfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
 
86
        break;
 
87
    case 16:
 
88
        cfb16GetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
 
89
        break;
 
90
    case 32:
 
91
        cfb32GetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
 
92
        break;
 
93
    }
 
94
    return;
 
95
}
 
96
 
 
97
static void
 
98
sunCfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine)
 
99
    DrawablePtr pDrawable;
 
100
    int         sx, sy, w, h;
 
101
    unsigned int format;
 
102
    unsigned long planeMask;
 
103
    char        *pdstLine;
 
104
{
 
105
    switch (pDrawable->bitsPerPixel)
 
106
    {
 
107
    case 1:
 
108
        mfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
 
109
        break;
 
110
    case 8:
 
111
        cfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
 
112
        break;
 
113
    case 16:
 
114
        cfb16GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
 
115
        break;
 
116
    case 32:
 
117
        cfb32GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
 
118
        break;
 
119
    }
 
120
}
 
121
 
 
122
Bool
 
123
sunCfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
 
124
    register ScreenPtr pScreen;
 
125
    pointer pbits;              /* pointer to screen bitmap */
 
126
    int xsize, ysize;           /* in pixels */
 
127
    int dpix, dpiy;             /* dots per inch */
 
128
    int width;                  /* pixel width of frame buffer */
 
129
    int bpp;                    /* bits per pixel of root */
 
130
{
 
131
    extern int          cfbWindowPrivateIndex;
 
132
    extern int          cfbGCPrivateIndex;
 
133
    int ret;
 
134
 
 
135
    sunRegisterPixmapFormat( /* depth */ 1,  /* bits per pixel */ 1);
 
136
    sunRegisterPixmapFormat( /* depth */ 8,  /* bits per pixel */ 8);
 
137
    sunRegisterPixmapFormat( /* depth */ 12,  /* bits per pixel */ 16);
 
138
    sunRegisterPixmapFormat( /* depth */ 24,  /* bits per pixel */ 32);
 
139
 
 
140
    switch (bpp) {
 
141
    case 8:
 
142
        ret = cfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width);
 
143
        break;
 
144
    case 16:
 
145
        ret = cfb16SetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width);
 
146
        break;
 
147
    case 32:
 
148
        ret = cfb32SetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width);
 
149
        break;
 
150
    default:
 
151
        return FALSE;
 
152
    }
 
153
    pScreen->CreateGC = sunCfbCreateGC;
 
154
    pScreen->GetImage = sunCfbGetImage;
 
155
    pScreen->GetSpans = sunCfbGetSpans;
 
156
    return ret;
 
157
}
 
158
 
 
159
extern BSFuncRec        cfbBSFuncRec, cfb16BSFuncRec, cfb32BSFuncRec;
 
160
extern int  cfb16ScreenPrivateIndex, cfb32ScreenPrivateIndex;
 
161
extern Bool cfbCloseScreen(), cfb16CloseScreen(), cfb32CloseScreen();
 
162
 
 
163
Bool
 
164
sunCfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
 
165
    register ScreenPtr pScreen;
 
166
    pointer pbits;              /* pointer to screen bitmap */
 
167
    int xsize, ysize;           /* in pixels */
 
168
    int dpix, dpiy;             /* dots per inch */
 
169
    int width;                  /* pixel width of frame buffer */
 
170
    int bpp;
 
171
{
 
172
    int         i;
 
173
    pointer     oldDevPrivate;
 
174
    VisualPtr   visuals;
 
175
    int         nvisuals;
 
176
    DepthPtr    depths;
 
177
    int         ndepths;
 
178
    VisualID    defaultVisual;
 
179
    int         rootdepth;
 
180
 
 
181
    if (!cfbInitVisuals(&visuals, &depths, &nvisuals, &ndepths,
 
182
                        &rootdepth, &defaultVisual, 1 << (bpp - 1), 8))
 
183
        return FALSE;
 
184
    oldDevPrivate = pScreen->devPrivate;
 
185
    if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
 
186
                        rootdepth, ndepths, depths,
 
187
                        defaultVisual, nvisuals, visuals))
 
188
        return FALSE;
 
189
    switch (bpp)
 
190
    {
 
191
    case 8:
 
192
        pScreen->CloseScreen = cfbCloseScreen;
 
193
        pScreen->BackingStoreFuncs = cfbBSFuncRec;
 
194
        break;
 
195
    case 16:
 
196
        pScreen->CloseScreen = cfb16CloseScreen;
 
197
        pScreen->devPrivates[cfb16ScreenPrivateIndex].ptr =
 
198
            pScreen->devPrivate;
 
199
        pScreen->devPrivate = oldDevPrivate;
 
200
        pScreen->BackingStoreFuncs = cfb16BSFuncRec;
 
201
        break;
 
202
    case 32:
 
203
        pScreen->CloseScreen = cfb32CloseScreen;
 
204
        pScreen->devPrivates[cfb32ScreenPrivateIndex].ptr =
 
205
            pScreen->devPrivate;
 
206
        pScreen->devPrivate = oldDevPrivate;
 
207
        pScreen->BackingStoreFuncs = cfb32BSFuncRec;
 
208
        break;
 
209
    }
 
210
    return TRUE;
 
211
}
 
212
 
 
213
 
 
214
Bool
 
215
sunCfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
 
216
    register ScreenPtr pScreen;
 
217
    pointer pbits;              /* pointer to screen bitmap */
 
218
    int xsize, ysize;           /* in pixels */
 
219
    int dpix, dpiy;             /* dots per inch */
 
220
    int width;                  /* pixel width of frame buffer */
 
221
    int bpp;
 
222
{
 
223
    if (!sunCfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy,
 
224
                           width, bpp))
 
225
        return FALSE;
 
226
    return sunCfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix,
 
227
                                  dpiy, width, bpp);
 
228
}
 
229
 
 
230
 
 
231
#else /* SINGLEDEPTH */
 
232
 
 
233
/* stuff for 8-bit only server */
 
234
 
 
235
Bool
 
236
sunCfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
 
237
    register ScreenPtr pScreen;
 
238
    pointer pbits;              /* pointer to screen bitmap */
 
239
    int xsize, ysize;           /* in pixels */
 
240
    int dpix, dpiy;             /* dots per inch */
 
241
    int width;                  /* pixel width of frame buffer */
 
242
    int bpp;                    /* bits per pixel of root */
 
243
{
 
244
    sunRegisterPixmapFormat( /* depth */ 1, /* bits per pixel */ 1);
 
245
    sunRegisterPixmapFormat( /* depth */ 8,  /* bits per pixel */ 8);
 
246
    return cfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy,
 
247
                          width);
 
248
}
 
249
 
 
250
Bool
 
251
sunCfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
 
252
    register ScreenPtr pScreen;
 
253
    pointer pbits;              /* pointer to screen bitmap */
 
254
    int xsize, ysize;           /* in pixels */
 
255
    int dpix, dpiy;             /* dots per inch */
 
256
    int width;                  /* pixel width of frame buffer */
 
257
    int bpp;
 
258
{
 
259
    return cfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy,
 
260
                               width);
 
261
}
 
262
 
 
263
Bool
 
264
sunCfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
 
265
    register ScreenPtr pScreen;
 
266
    pointer pbits;              /* pointer to screen bitmap */
 
267
    int xsize, ysize;           /* in pixels */
 
268
    int dpix, dpiy;             /* dots per inch */
 
269
    int width;                  /* pixel width of frame buffer */
 
270
    int bpp;
 
271
{
 
272
    sunRegisterPixmapFormat( /* depth */ 1, /* bits per pixel */ 1);
 
273
    sunRegisterPixmapFormat( /* depth */ 8,  /* bits per pixel */ 8);
 
274
    return cfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width);
 
275
}
 
276
 
 
277
#endif /* SINGLEDEPTH */