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

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/hw/xfree86/xf24_32bpp/cfbscrinit.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
/* $XFree86: xc/programs/Xserver/hw/xfree86/xf24_32bpp/cfbscrinit.c,v 1.4 1999/08/14 10:50:16 dawes Exp $ */
 
2
 
 
3
 
 
4
#include "X.h"
 
5
#include "Xmd.h"
 
6
#include "misc.h"
 
7
#include "servermd.h"
 
8
#include "scrnintstr.h"
 
9
#include "pixmapstr.h"
 
10
#include "resource.h"
 
11
#include "colormap.h"
 
12
#include "colormapst.h"
 
13
#define PSZ 8
 
14
#include "cfb.h"
 
15
#undef PSZ
 
16
#include "cfb24.h"
 
17
#include "cfb32.h"
 
18
#include "cfb24_32.h"
 
19
#include "mi.h"
 
20
#include "micmap.h"
 
21
#include "mistruct.h"
 
22
#include "dix.h"
 
23
#include "mibstore.h"
 
24
 
 
25
/* CAUTION:  We require that cfb24 and cfb32 were NOT 
 
26
        compiled with CFB_NEED_SCREEN_PRIVATE */
 
27
 
 
28
static BSFuncRec cfb24_32BSFuncRec = {
 
29
    cfb24SaveAreas,
 
30
    cfb24RestoreAreas,
 
31
    (BackingStoreSetClipmaskRgnProcPtr) 0,
 
32
    (BackingStoreGetImagePixmapProcPtr) 0,
 
33
    (BackingStoreGetSpansPixmapProcPtr) 0,
 
34
};
 
35
 
 
36
 
 
37
int cfb24_32GCIndex = 1;
 
38
int cfb24_32PixmapIndex = 1;
 
39
 
 
40
static unsigned long cfb24_32Generation = 0;
 
41
extern WindowPtr *WindowTable;
 
42
 
 
43
static Bool
 
44
cfb24_32AllocatePrivates(ScreenPtr pScreen)
 
45
{
 
46
   if(cfb24_32Generation != serverGeneration) {
 
47
        if( ((cfb24_32GCIndex = AllocateGCPrivateIndex()) < 0) |
 
48
            ((cfb24_32PixmapIndex = AllocatePixmapPrivateIndex()) < 0))
 
49
            return FALSE;
 
50
        cfb24_32Generation = serverGeneration;
 
51
   }
 
52
   
 
53
   
 
54
   /* All cfb will have the same GC and Window private indicies */
 
55
   if(!mfbAllocatePrivates(pScreen,&cfbWindowPrivateIndex, &cfbGCPrivateIndex))
 
56
        return FALSE;
 
57
 
 
58
   /* The cfb indicies are the mfb indicies. Reallocating them resizes them */ 
 
59
   if(!AllocateWindowPrivate(pScreen,cfbWindowPrivateIndex,sizeof(cfbPrivWin)))
 
60
        return FALSE;
 
61
 
 
62
   if(!AllocateGCPrivate(pScreen, cfbGCPrivateIndex, sizeof(cfbPrivGC)))
 
63
        return FALSE;
 
64
 
 
65
   if(!AllocateGCPrivate(pScreen, cfb24_32GCIndex, sizeof(cfb24_32GCRec)))
 
66
        return FALSE;
 
67
 
 
68
   if(!AllocatePixmapPrivate(
 
69
        pScreen, cfb24_32PixmapIndex, sizeof(cfb24_32PixmapRec)))
 
70
        return FALSE;
 
71
 
 
72
 
 
73
   return TRUE;
 
74
}
 
75
 
 
76
static Bool
 
77
cfb24_32SetupScreen(
 
78
    ScreenPtr pScreen,
 
79
    pointer pbits,              /* pointer to screen bitmap */
 
80
    int xsize, int ysize,       /* in pixels */
 
81
    int dpix, int dpiy,         /* dots per inch */
 
82
    int width                   /* pixel width of frame buffer */
 
83
){
 
84
    if (!cfb24_32AllocatePrivates(pScreen))
 
85
        return FALSE;
 
86
    pScreen->defColormap = FakeClientID(0);
 
87
    /* let CreateDefColormap do whatever it wants for pixels */ 
 
88
    pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
 
89
    pScreen->QueryBestSize = mfbQueryBestSize;
 
90
    /* SaveScreen */
 
91
    pScreen->GetImage = cfb24_32GetImage;
 
92
    pScreen->GetSpans = cfb24_32GetSpans;
 
93
    pScreen->CreateWindow = cfb24_32CreateWindow;
 
94
    pScreen->DestroyWindow = cfb24_32DestroyWindow;     
 
95
    pScreen->PositionWindow = cfb24_32PositionWindow;
 
96
    pScreen->ChangeWindowAttributes = cfb24_32ChangeWindowAttributes;
 
97
    pScreen->RealizeWindow = cfb24MapWindow;                    /* OK */
 
98
    pScreen->UnrealizeWindow = cfb24UnmapWindow;                /* OK */
 
99
    pScreen->PaintWindowBackground = cfb24PaintWindow;          /* OK */
 
100
    pScreen->PaintWindowBorder = cfb24PaintWindow;              /* OK */
 
101
    pScreen->CopyWindow = cfb24_32CopyWindow;
 
102
    pScreen->CreatePixmap = cfb24_32CreatePixmap;
 
103
    pScreen->DestroyPixmap = cfb24_32DestroyPixmap;
 
104
    pScreen->RealizeFont = mfbRealizeFont;
 
105
    pScreen->UnrealizeFont = mfbUnrealizeFont;
 
106
    pScreen->CreateGC = cfb24_32CreateGC;
 
107
    pScreen->CreateColormap = miInitializeColormap;
 
108
    pScreen->DestroyColormap = (void (*)())NoopDDA;
 
109
    pScreen->InstallColormap = miInstallColormap;
 
110
    pScreen->UninstallColormap = miUninstallColormap;
 
111
    pScreen->ListInstalledColormaps = miListInstalledColormaps;
 
112
    pScreen->StoreColors = (void (*)())NoopDDA;
 
113
    pScreen->ResolveColor = miResolveColor;
 
114
    pScreen->BitmapToRegion = mfbPixmapToRegion;
 
115
 
 
116
    mfbRegisterCopyPlaneProc (pScreen, miCopyPlane);
 
117
    return TRUE;
 
118
}
 
119
 
 
120
typedef struct {
 
121
    pointer pbits; 
 
122
    int width;   
 
123
} miScreenInitParmsRec, *miScreenInitParmsPtr;
 
124
 
 
125
static Bool
 
126
cfb24_32CreateScreenResources(ScreenPtr pScreen)
 
127
{
 
128
    miScreenInitParmsPtr pScrInitParms;
 
129
    int pitch;
 
130
    Bool retval;
 
131
 
 
132
    /* get the pitch before mi destroys it */
 
133
    pScrInitParms = (miScreenInitParmsPtr)pScreen->devPrivate;
 
134
    pitch = BitmapBytePad(pScrInitParms->width * 24);
 
135
 
 
136
    if((retval = miCreateScreenResources(pScreen))) {
 
137
        /* fix the screen pixmap */
 
138
        PixmapPtr pPix = (PixmapPtr)pScreen->devPrivate;
 
139
        pPix->drawable.bitsPerPixel = 24;
 
140
        pPix->devKind = pitch;
 
141
    }
 
142
 
 
143
    return retval;
 
144
}
 
145
 
 
146
 
 
147
static Bool
 
148
cfb24_32FinishScreenInit(
 
149
    ScreenPtr pScreen,
 
150
    pointer pbits,              /* pointer to screen bitmap */
 
151
    int xsize, int ysize,       /* in pixels */
 
152
    int dpix, int dpiy,         /* dots per inch */
 
153
    int width                   /* pixel width of frame buffer */
 
154
){
 
155
    VisualPtr   visuals;
 
156
    DepthPtr    depths;
 
157
    int         nvisuals;
 
158
    int         ndepths;
 
159
    int         rootdepth;
 
160
    VisualID    defaultVisual;
 
161
 
 
162
    rootdepth = 0;
 
163
    if (!miInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &rootdepth,
 
164
                         &defaultVisual,((unsigned long)1<<(24-1)), 8, -1))
 
165
        return FALSE;
 
166
    if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
 
167
                        rootdepth, ndepths, depths,
 
168
                        defaultVisual, nvisuals, visuals))
 
169
        return FALSE;
 
170
 
 
171
    pScreen->BackingStoreFuncs = cfb24_32BSFuncRec;
 
172
    pScreen->CreateScreenResources = cfb24_32CreateScreenResources;
 
173
    pScreen->CloseScreen = cfb32CloseScreen;            /* OK */
 
174
    pScreen->GetScreenPixmap = cfb32GetScreenPixmap;    /* OK */
 
175
    pScreen->SetScreenPixmap = cfb32SetScreenPixmap;    /* OK */
 
176
    return TRUE;
 
177
}
 
178
 
 
179
Bool
 
180
cfb24_32ScreenInit(
 
181
    ScreenPtr pScreen,
 
182
    pointer pbits,              /* pointer to screen bitmap */
 
183
    int xsize, int ysize,       /* in pixels */
 
184
    int dpix, int dpiy,         /* dots per inch */
 
185
    int width                   /* pixel width of frame buffer */
 
186
){
 
187
    if (!cfb24_32SetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width))
 
188
        return FALSE;
 
189
    return cfb24_32FinishScreenInit(
 
190
                pScreen, pbits, xsize, ysize, dpix, dpiy, width);
 
191
}
 
192