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

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/hw/xfree86/xf24_32bpp/cfbgcmisc.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/cfbgcmisc.c,v 1.1 1999/01/23 09:56:14 dawes Exp $ */
 
2
 
 
3
#include "X.h"
 
4
#include "Xmd.h"
 
5
#include "Xproto.h"
 
6
#define PSZ 8
 
7
#include "cfb.h"
 
8
#undef PSZ
 
9
#include "cfb24.h"
 
10
#include "cfb32.h"
 
11
#include "cfb24_32.h"
 
12
#include "fontstruct.h"
 
13
#include "dixfontstr.h"
 
14
#include "gcstruct.h"
 
15
#include "windowstr.h"
 
16
#include "pixmapstr.h"
 
17
#include "scrnintstr.h"
 
18
#include "region.h"
 
19
 
 
20
#include "mistruct.h"
 
21
#include "mibstore.h"
 
22
#include "migc.h"
 
23
 
 
24
 
 
25
static void cfb24_32ValidateGC(GCPtr, unsigned long, DrawablePtr);
 
26
static void cfb24_32DestroyGC(GCPtr pGC);
 
27
static void cfb24_32ChangeGC(GCPtr pGC, unsigned long mask);
 
28
static void cfb24_32CopyGC(GCPtr pGCSrc, unsigned long changes, GCPtr pGCDst);
 
29
 
 
30
static
 
31
GCFuncs cfb24_32GCFuncs = {
 
32
    cfb24_32ValidateGC,
 
33
    cfb24_32ChangeGC,
 
34
    cfb24_32CopyGC,
 
35
    cfb24_32DestroyGC,
 
36
    miChangeClip,
 
37
    miDestroyClip,
 
38
    miCopyClip,
 
39
};
 
40
 
 
41
static void
 
42
cfb24_32DestroyGC(GCPtr pGC)
 
43
{
 
44
    cfb24_32GCPtr pGCPriv = CFB24_32_GET_GC_PRIVATE(pGC);
 
45
 
 
46
    if (pGC->freeCompClip)
 
47
        REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip);
 
48
    if(pGCPriv->Ops24bpp)
 
49
        miDestroyGCOps(pGCPriv->Ops24bpp);
 
50
    if(pGCPriv->Ops32bpp)
 
51
        miDestroyGCOps(pGCPriv->Ops32bpp);
 
52
}
 
53
 
 
54
static void
 
55
cfb24_32ChangeGC(
 
56
    GCPtr           pGC,
 
57
    unsigned long   mask
 
58
){
 
59
   
 
60
   if((mask & GCTile) && pGC->tile.pixmap && !pGC->tileIsPixel) {
 
61
        PixmapPtr pPix = pGC->tile.pixmap;
 
62
        cfb24_32PixmapPtr pixPriv = CFB24_32_GET_PIXMAP_PRIVATE(pPix);
 
63
 
 
64
        if(pixPriv->pix && (pPix->refcnt != pixPriv->pix->refcnt))
 
65
            pixPriv->pix->refcnt = pPix->refcnt;
 
66
   }
 
67
 
 
68
   return;
 
69
}
 
70
 
 
71
static void
 
72
cfb24_32CopyGC(
 
73
    GCPtr           pGCSrc,
 
74
    unsigned long   changes,
 
75
    GCPtr           pGCDst
 
76
){
 
77
   if((changes & GCTile) && pGCDst->tile.pixmap && !pGCDst->tileIsPixel) {
 
78
        PixmapPtr pPix = pGCDst->tile.pixmap;
 
79
        cfb24_32PixmapPtr pixPriv = CFB24_32_GET_PIXMAP_PRIVATE(pPix);
 
80
 
 
81
        if(pixPriv->pix && (pPix->refcnt != pixPriv->pix->refcnt))
 
82
            pixPriv->pix->refcnt = pPix->refcnt;
 
83
   }
 
84
 
 
85
   return;
 
86
}
 
87
 
 
88
 
 
89
 
 
90
Bool
 
91
cfb24_32CreateGC(GCPtr pGC)
 
92
{
 
93
    cfb24_32GCPtr pGCPriv;
 
94
    cfbPrivGC *pPriv;
 
95
 
 
96
    if (PixmapWidthPaddingInfo[pGC->depth].padPixelsLog2 == LOG2_BITMAP_PAD)
 
97
        return (mfbCreateGC(pGC));
 
98
 
 
99
    pGC->clientClip = NULL;
 
100
    pGC->clientClipType = CT_NONE;
 
101
    pGC->miTranslate = 1;
 
102
    pGC->fExpose = TRUE;
 
103
    pGC->freeCompClip = FALSE;
 
104
    pGC->pRotatedPixmap = (PixmapPtr) NULL;
 
105
 
 
106
    pPriv = cfbGetGCPrivate(pGC);
 
107
    pPriv->rop = pGC->alu;
 
108
    pPriv->oneRect = FALSE;
 
109
 
 
110
    pGC->ops = NULL;
 
111
    pGC->funcs = &cfb24_32GCFuncs;
 
112
 
 
113
    pGCPriv = CFB24_32_GET_GC_PRIVATE(pGC);
 
114
    pGCPriv->Ops24bpp = NULL;
 
115
    pGCPriv->Ops32bpp = NULL;
 
116
    pGCPriv->OpsAre24bpp = FALSE;
 
117
    pGCPriv->changes = 0;
 
118
        
 
119
    return TRUE;
 
120
}
 
121
 
 
122
 
 
123
static void
 
124
cfb24_32ValidateGC(
 
125
    GCPtr pGC,
 
126
    unsigned long changes,
 
127
    DrawablePtr pDraw
 
128
){
 
129
    cfb24_32GCPtr pGCPriv = CFB24_32_GET_GC_PRIVATE(pGC);
 
130
 
 
131
    if(pDraw->bitsPerPixel == 32) {
 
132
        if(pGCPriv->OpsAre24bpp) {
 
133
            int origChanges = changes;
 
134
            pGC->ops = pGCPriv->Ops32bpp;
 
135
            changes |= pGCPriv->changes;
 
136
            pGCPriv->changes = origChanges;
 
137
            pGCPriv->OpsAre24bpp = FALSE;
 
138
        } else 
 
139
            pGCPriv->changes |= changes;
 
140
 
 
141
        if((pGC->fillStyle == FillTiled) && 
 
142
           (pGC->tile.pixmap->drawable.bitsPerPixel == 24)){
 
143
           pGC->tile.pixmap = cfb24_32RefreshPixmap(pGC->tile.pixmap);
 
144
           changes |= GCTile;
 
145
        }
 
146
 
 
147
        cfb24_32ValidateGC32(pGC, changes, pDraw);
 
148
        pGCPriv->Ops32bpp = pGC->ops;
 
149
    } else {  /* bitsPerPixel == 24 */
 
150
        if(!pGCPriv->OpsAre24bpp) {
 
151
            int origChanges = changes;
 
152
            pGC->ops = pGCPriv->Ops24bpp;
 
153
            changes |= pGCPriv->changes;
 
154
            pGCPriv->changes = origChanges;
 
155
            pGCPriv->OpsAre24bpp = TRUE;
 
156
        } else 
 
157
            pGCPriv->changes |= changes;
 
158
 
 
159
        if((pGC->fillStyle == FillTiled) && 
 
160
           (pGC->tile.pixmap->drawable.bitsPerPixel == 32)){
 
161
           pGC->tile.pixmap = cfb24_32RefreshPixmap(pGC->tile.pixmap);
 
162
           changes |= GCTile;
 
163
        }
 
164
 
 
165
        cfb24_32ValidateGC24(pGC, changes, pDraw);
 
166
        pGCPriv->Ops24bpp = pGC->ops;
 
167
    }
 
168
 
 
169
}
 
170