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

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/mfb/mfbscrinit.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/mfb/mfbscrinit.c,v 3.9 2003/02/18 21:30:01 tsi Exp $ */
 
2
/***********************************************************
 
3
 
 
4
Copyright 1987, 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 in
 
13
all copies or substantial portions of the Software.
 
14
 
 
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
16
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
17
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
18
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
19
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
20
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
21
 
 
22
Except as contained in this notice, the name of The Open Group shall not be
 
23
used in advertising or otherwise to promote the sale, use or other dealings
 
24
in this Software without prior written authorization from The Open Group.
 
25
 
 
26
 
 
27
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
28
 
 
29
                        All Rights Reserved
 
30
 
 
31
Permission to use, copy, modify, and distribute this software and its 
 
32
documentation for any purpose and without fee is hereby granted, 
 
33
provided that the above copyright notice appear in all copies and that
 
34
both that copyright notice and this permission notice appear in 
 
35
supporting documentation, and that the name of Digital not be
 
36
used in advertising or publicity pertaining to distribution of the
 
37
software without specific, written prior permission.  
 
38
 
 
39
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 
40
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 
41
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 
42
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 
43
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 
44
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 
45
SOFTWARE.
 
46
 
 
47
******************************************************************/
 
48
/* $Xorg: mfbscrinit.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $ */
 
49
 
 
50
#include "X.h"
 
51
#include "Xproto.h"     /* for xColorItem */
 
52
#include "Xmd.h"
 
53
#include "scrnintstr.h"
 
54
#include "pixmapstr.h"
 
55
#include "windowstr.h"
 
56
#include "resource.h"
 
57
#include "colormap.h"
 
58
#include "mfb.h"
 
59
#include "mistruct.h"
 
60
#include "dix.h"
 
61
#include "mi.h"
 
62
#include "mibstore.h"
 
63
#include "migc.h"
 
64
#include "servermd.h"
 
65
 
 
66
#ifdef PIXMAP_PER_WINDOW
 
67
int frameWindowPrivateIndex;
 
68
#endif
 
69
int mfbWindowPrivateIndex;
 
70
int mfbGCPrivateIndex;
 
71
static unsigned long mfbGeneration = 0;
 
72
 
 
73
static VisualRec visual = {
 
74
/* vid  class       bpRGB cmpE nplan rMask gMask bMask oRed oGreen oBlue */
 
75
   0,   StaticGray, 1,    2,   1,    0,    0,    0,    0,   0,     0
 
76
};
 
77
 
 
78
static VisualID VID;
 
79
 
 
80
static DepthRec depth = {
 
81
/* depth        numVid          vids */
 
82
    1,          1,              &VID
 
83
};
 
84
 
 
85
#ifndef LOWMEMFTPT
 
86
 
 
87
BSFuncRec mfbBSFuncRec = {
 
88
    mfbSaveAreas,
 
89
    mfbRestoreAreas,
 
90
    (BackingStoreSetClipmaskRgnProcPtr) 0,
 
91
    (BackingStoreGetImagePixmapProcPtr) 0,
 
92
    (BackingStoreGetSpansPixmapProcPtr) 0,
 
93
};
 
94
 
 
95
#endif /* ifndef LOWMEMFTPT */
 
96
 
 
97
Bool
 
98
mfbAllocatePrivates(pScreen, pWinIndex, pGCIndex)
 
99
    ScreenPtr pScreen;
 
100
    int *pWinIndex, *pGCIndex;
 
101
{
 
102
    if (mfbGeneration != serverGeneration)
 
103
    {
 
104
#ifdef PIXMAP_PER_WINDOW
 
105
        frameWindowPrivateIndex = AllocateWindowPrivateIndex();
 
106
#endif
 
107
        mfbWindowPrivateIndex = AllocateWindowPrivateIndex();
 
108
        mfbGCPrivateIndex = miAllocateGCPrivateIndex();
 
109
        visual.vid = FakeClientID(0);
 
110
        VID = visual.vid;
 
111
        mfbGeneration = serverGeneration;
 
112
    }
 
113
    if (pWinIndex)
 
114
        *pWinIndex = mfbWindowPrivateIndex;
 
115
    if (pGCIndex)
 
116
        *pGCIndex = mfbGCPrivateIndex;
 
117
    pScreen->GetWindowPixmap = mfbGetWindowPixmap;
 
118
    pScreen->SetWindowPixmap = mfbSetWindowPixmap;
 
119
    return (AllocateWindowPrivate(pScreen, mfbWindowPrivateIndex,
 
120
                                  sizeof(mfbPrivWin)) &&
 
121
            AllocateGCPrivate(pScreen, mfbGCPrivateIndex, sizeof(mfbPrivGC)));
 
122
}
 
123
 
 
124
#ifndef LOWMEMFTPT
 
125
 
 
126
/* dts * (inch/dot) * (25.4 mm / inch) = mm */
 
127
Bool
 
128
mfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
 
129
    register ScreenPtr pScreen;
 
130
    pointer pbits;              /* pointer to screen bitmap */
 
131
    int xsize, ysize;           /* in pixels */
 
132
    int dpix, dpiy;             /* dots per inch */
 
133
    int width;                  /* pixel width of frame buffer */
 
134
{
 
135
    if  (!mfbAllocatePrivates(pScreen, (int *)NULL, (int *)NULL))
 
136
        return FALSE;
 
137
    pScreen->defColormap = (Colormap) FakeClientID(0);
 
138
    /* whitePixel, blackPixel */
 
139
    pScreen->QueryBestSize = mfbQueryBestSize;
 
140
    /* SaveScreen */
 
141
    pScreen->GetImage = mfbGetImage;
 
142
    pScreen->GetSpans = mfbGetSpans;
 
143
    pScreen->CreateWindow = mfbCreateWindow;
 
144
    pScreen->DestroyWindow = mfbDestroyWindow;
 
145
    pScreen->PositionWindow = mfbPositionWindow;
 
146
    pScreen->ChangeWindowAttributes = mfbChangeWindowAttributes;
 
147
    pScreen->RealizeWindow = mfbMapWindow;
 
148
    pScreen->UnrealizeWindow = mfbUnmapWindow;
 
149
    pScreen->PaintWindowBackground = mfbPaintWindow;
 
150
    pScreen->PaintWindowBorder = mfbPaintWindow;
 
151
    pScreen->CopyWindow = mfbCopyWindow;
 
152
    pScreen->CreatePixmap = mfbCreatePixmap;
 
153
    pScreen->DestroyPixmap = mfbDestroyPixmap;
 
154
    pScreen->RealizeFont = mfbRealizeFont;
 
155
    pScreen->UnrealizeFont = mfbUnrealizeFont;
 
156
    pScreen->CreateGC = mfbCreateGC;
 
157
    pScreen->CreateColormap = mfbCreateColormap;
 
158
    pScreen->DestroyColormap = mfbDestroyColormap;
 
159
    pScreen->InstallColormap = mfbInstallColormap;
 
160
    pScreen->UninstallColormap = mfbUninstallColormap;
 
161
    pScreen->ListInstalledColormaps = mfbListInstalledColormaps;
 
162
    pScreen->StoreColors = (StoreColorsProcPtr)NoopDDA;
 
163
    pScreen->ResolveColor = mfbResolveColor;
 
164
    pScreen->BitmapToRegion = mfbPixmapToRegion;
 
165
    if (!miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
 
166
                        1, 1, &depth, VID, 1, &visual))
 
167
        return FALSE;
 
168
    pScreen->BackingStoreFuncs = mfbBSFuncRec;
 
169
    return TRUE;
 
170
}
 
171
#endif /* ifndef LOWMEMFTPT */
 
172
 
 
173
PixmapPtr
 
174
mfbGetWindowPixmap(pWin)
 
175
    WindowPtr pWin;
 
176
{
 
177
#ifdef PIXMAP_PER_WINDOW
 
178
    return (PixmapPtr)(pWin->devPrivates[frameWindowPrivateIndex].ptr);
 
179
#else
 
180
    ScreenPtr pScreen = pWin->drawable.pScreen;
 
181
 
 
182
    return (* pScreen->GetScreenPixmap)(pScreen);
 
183
#endif
 
184
}
 
185
 
 
186
void
 
187
mfbSetWindowPixmap(pWin, pPix)
 
188
    WindowPtr pWin;
 
189
    PixmapPtr pPix;
 
190
{
 
191
#ifdef PIXMAP_PER_WINDOW
 
192
    pWin->devPrivates[frameWindowPrivateIndex].ptr = (pointer)pPix;
 
193
#else
 
194
    (* pWin->drawable.pScreen->SetScreenPixmap)(pPix);
 
195
#endif
 
196
}
 
197