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

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/hw/xfree86/xaa/xaaOffscreen.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/xaa/xaaOffscreen.c,v 1.6 2001/07/19 18:50:16 mvojkovi Exp $ */
 
2
 
 
3
/*
 
4
   Copyright (c) 1999 -  The XFree86 Project Inc.
 
5
 
 
6
   Written by Mark Vojkovich
 
7
 
 
8
*/ 
 
9
 
 
10
#include "misc.h"
 
11
#include "xf86.h"
 
12
#include "xf86_ansic.h"
 
13
#include "xf86_OSproc.h"
 
14
 
 
15
#include "X.h"
 
16
#include "scrnintstr.h"
 
17
#include "pixmapstr.h"
 
18
#include "windowstr.h"
 
19
#include "xf86str.h"
 
20
#include "mi.h"
 
21
#include "miline.h"
 
22
#include "xaa.h"
 
23
#include "xaalocal.h"
 
24
#include "xaawrap.h"
 
25
#include "xf86fbman.h"
 
26
#include "servermd.h"
 
27
 
 
28
void
 
29
XAAMoveOutOffscreenPixmaps(ScreenPtr pScreen)
 
30
{
 
31
    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
 
32
    PixmapLinkPtr pLink = infoRec->OffscreenPixmaps;
 
33
    XAAPixmapPtr pPriv;
 
34
    
 
35
    while(pLink) {
 
36
        pPriv = XAA_GET_PIXMAP_PRIVATE(pLink->pPix);
 
37
        pLink->area = pPriv->offscreenArea;
 
38
        XAAMoveOutOffscreenPixmap(pLink->pPix); 
 
39
        pLink = pLink->next;
 
40
    }    
 
41
}
 
42
 
 
43
 
 
44
 
 
45
void
 
46
XAAMoveInOffscreenPixmaps(ScreenPtr pScreen)
 
47
{
 
48
    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
 
49
    PixmapLinkPtr pLink = infoRec->OffscreenPixmaps;
 
50
    PixmapPtr pPix, pScreenPix, tmpPix;
 
51
    pointer data;
 
52
    XAAPixmapPtr pPriv;
 
53
    GCPtr pGC;
 
54
    FBAreaPtr area;
 
55
 
 
56
    pScreenPix = (*pScreen->GetScreenPixmap)(pScreen);
 
57
 
 
58
    while(pLink) {
 
59
        pPix = pLink->pPix;
 
60
        pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
 
61
        area = pLink->area;
 
62
 
 
63
        data = pPix->devPrivate.ptr;
 
64
        tmpPix = GetScratchPixmapHeader(pScreen, 
 
65
                pPix->drawable.width, pPix->drawable.height, 
 
66
                pPix->drawable.depth, pPix->drawable.bitsPerPixel, 
 
67
                pPix->devKind, data);
 
68
 
 
69
        pPriv->freeData = FALSE;
 
70
 
 
71
        pPix->drawable.x = area->box.x1;
 
72
        pPix->drawable.y = area->box.y1;
 
73
        pPix->devKind = pScreenPix->devKind;
 
74
        pPix->devPrivate.ptr = pScreenPix->devPrivate.ptr;
 
75
        pPix->drawable.bitsPerPixel = infoRec->pScrn->bitsPerPixel;
 
76
        pPix->drawable.serialNumber = NEXT_SERIAL_NUMBER;
 
77
 
 
78
        if(!tmpPix) {
 
79
            pPriv->offscreenArea = area;
 
80
            xfree(data);
 
81
            pLink = pLink->next;
 
82
            continue;
 
83
        }
 
84
        
 
85
        pGC = GetScratchGC(pPix->drawable.depth, pScreen);
 
86
        ValidateGC((DrawablePtr)pPix, pGC);
 
87
 
 
88
        (*pGC->ops->CopyArea)((DrawablePtr)tmpPix, (DrawablePtr)pPix, pGC, 
 
89
                0, 0, pPix->drawable.width, pPix->drawable.height, 0, 0);       
 
90
 
 
91
        xfree(data);
 
92
        tmpPix->devPrivate.ptr = NULL;
 
93
 
 
94
        FreeScratchGC(pGC);
 
95
        FreeScratchPixmapHeader(tmpPix);
 
96
 
 
97
        pPriv->offscreenArea = area;
 
98
        pLink->area = NULL;
 
99
        pLink = pLink->next;
 
100
    }    
 
101
}
 
102
 
 
103
 
 
104
void
 
105
XAARemoveAreaCallback(FBAreaPtr area)
 
106
{
 
107
    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(area->pScreen);
 
108
    PixmapPtr pPix = (PixmapPtr)area->devPrivate.ptr;
 
109
    XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
 
110
 
 
111
    XAAMoveOutOffscreenPixmap(pPix);
 
112
 
 
113
    pPriv->flags &= ~OFFSCREEN; 
 
114
 
 
115
    DELIST_OFFSCREEN_PIXMAP(pPix);
 
116
}
 
117
 
 
118
void
 
119
XAAMoveOutOffscreenPixmap(PixmapPtr pPix) 
 
120
{
 
121
    ScreenPtr pScreen = pPix->drawable.pScreen;
 
122
    XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
 
123
    int width, height, devKind, bitsPerPixel;
 
124
    PixmapPtr tmpPix;
 
125
    unsigned char *data;
 
126
    GCPtr pGC;
 
127
 
 
128
    width = pPix->drawable.width;
 
129
    height = pPix->drawable.height;
 
130
    bitsPerPixel = pPix->drawable.bitsPerPixel;
 
131
 
 
132
    devKind = BitmapBytePad(width * bitsPerPixel);
 
133
    if(!(data = xalloc(devKind * height)))
 
134
        FatalError("Out of memory\n");
 
135
 
 
136
    tmpPix = GetScratchPixmapHeader(pScreen, width, height, 
 
137
                pPix->drawable.depth, bitsPerPixel, devKind, data);
 
138
    if(!tmpPix) {
 
139
        xfree(data);
 
140
        FatalError("Out of memory\n");
 
141
    }
 
142
 
 
143
    pGC = GetScratchGC(pPix->drawable.depth, pScreen);
 
144
    ValidateGC((DrawablePtr)tmpPix, pGC);
 
145
 
 
146
    (*pGC->ops->CopyArea)((DrawablePtr)pPix, (DrawablePtr)tmpPix,
 
147
                pGC, 0, 0, width, height, 0, 0);        
 
148
 
 
149
    FreeScratchGC(pGC);
 
150
    FreeScratchPixmapHeader(tmpPix);
 
151
 
 
152
    pPix->drawable.x = 0;
 
153
    pPix->drawable.y = 0;
 
154
    pPix->devKind = devKind;
 
155
    pPix->devPrivate.ptr = data;
 
156
    pPix->drawable.serialNumber = NEXT_SERIAL_NUMBER;
 
157
 
 
158
    pPriv->offscreenArea = NULL;
 
159
    pPriv->freeData = TRUE;
 
160
}