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

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/miext/shadow/shplanar8.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
/*
 
2
 * $XFree86: xc/programs/Xserver/miext/shadow/shplanar8.c,v 1.4 2001/10/28 03:34:16 tsi Exp $
 
3
 *
 
4
 * Copyright � 2000 Keith Packard
 
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, and that the name of Keith Packard not be used in
 
11
 * advertising or publicity pertaining to distribution of the software without
 
12
 * specific, written prior permission.  Keith Packard makes no
 
13
 * representations about the suitability of this software for any purpose.  It
 
14
 * is provided "as is" without express or implied warranty.
 
15
 *
 
16
 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
17
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 
18
 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
19
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 
20
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 
21
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 
22
 * PERFORMANCE OF THIS SOFTWARE.
 
23
 */
 
24
 
 
25
#include    "X.h"
 
26
#include    "scrnintstr.h"
 
27
#include    "windowstr.h"
 
28
#include    "font.h"
 
29
#include    "dixfontstr.h"
 
30
#include    "fontstruct.h"
 
31
#include    "mi.h"
 
32
#include    "regionstr.h"
 
33
#include    "globals.h"
 
34
#include    "gcstruct.h"
 
35
#include    "shadow.h"
 
36
#include    "fb.h"
 
37
 
 
38
/*
 
39
 * Expose 8bpp depth 4
 
40
 */
 
41
 
 
42
/*
 
43
 *  32->8 conversion:
 
44
 *
 
45
 *      7 6 5 4 3 2 1 0
 
46
 *      A B C D E F G H
 
47
 *
 
48
 *      3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
 
49
 *      1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
 
50
 * m1   D x x x x x x x C x x x x x x x B x x x x x x x A x x x x x x x     sha[0] << (7-(p))
 
51
 * m2   x x x x H x x x x x x x G x x x x x x x F x x x x x x x E x x x     sha[1] << (3-(p))
 
52
 * m3   D               C               B               A                   m1 & 0x80808080
 
53
 * m4           H               G               F               E           m2 & 0x08080808
 
54
 * m5   D       H       C       G       B       F       A       E           m3 | m4
 
55
 * m6                     D       H       C       G       B       F         m5 >> 9
 
56
 * m7   D       H       C D     G H     B C     F G     A B     E F         m5 | m6
 
57
 * m8                                       D       H       C D     G H     m7 >> 18
 
58
 * m9   D       H       C D     G H     B C D   F G H   A B C D E F G H     m7 | m8
 
59
 */
 
60
 
 
61
#define PL_SHIFT    8
 
62
#define PL_UNIT     (1 << PL_SHIFT)
 
63
#define PL_MASK     (PL_UNIT - 1)
 
64
 
 
65
#if 0
 
66
#define GetBits(p,o,d) { \
 
67
    CARD32      m1,m2,m3,m4,m5,m6,m7,m8; \
 
68
    m1 = sha[o] << (7 - (p)); \
 
69
    m2 = sha[(o)+1] << (3 - (p)); \
 
70
    m3 = m1 & 0x80808080; \
 
71
    m4 = m2 & 0x08080808; \
 
72
    m5 = m3 | m4; \
 
73
    m6 = m5 >> 9; \
 
74
    m7 = m5 | m6; \
 
75
    m8 = m7 >> 18; \
 
76
    d = m7 | m8; \
 
77
}
 
78
#else
 
79
#define GetBits(p,o,d) { \
 
80
    CARD32      m5,m7; \
 
81
    m5 = ((sha[o] << (7 - (p))) & 0x80808080) | ((sha[(o)+1] << (3 - (p))) & 0x08080808); \
 
82
    m7 = m5 | (m5 >> 9); \
 
83
    d = m7 | (m7 >> 18); \
 
84
}
 
85
#endif
 
86
 
 
87
void
 
88
shadowUpdatePlanar4x8 (ScreenPtr        pScreen,
 
89
                       shadowBufPtr     pBuf)
 
90
{
 
91
    RegionPtr   damage = &pBuf->damage;
 
92
    PixmapPtr   pShadow = pBuf->pPixmap;
 
93
    int         nbox = REGION_NUM_RECTS (damage);
 
94
    BoxPtr      pbox = REGION_RECTS (damage);
 
95
    CARD32      *shaBase, *shaLine, *sha;
 
96
    CARD8       s1, s2, s3, s4;
 
97
    FbStride    shaStride;
 
98
    int         scrBase, scrLine, scr;
 
99
    int         shaBpp;
 
100
    int         shaXoff, shaYoff;   /* XXX assumed to be zero */
 
101
    int         x, y, w, h, width;
 
102
    int         i;
 
103
    CARD32      *winBase = NULL, *win;
 
104
    CARD32      winSize;
 
105
    int         plane;
 
106
 
 
107
    fbGetStipDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff);
 
108
    while (nbox--)
 
109
    {
 
110
        x = pbox->x1 * shaBpp;
 
111
        y = pbox->y1;
 
112
        w = (pbox->x2 - pbox->x1) * shaBpp;
 
113
        h = pbox->y2 - pbox->y1;
 
114
 
 
115
        w = (w + (x & PL_MASK) + PL_MASK) >> PL_SHIFT;
 
116
        x &= ~PL_MASK;
 
117
        
 
118
        scrLine = (x >> PL_SHIFT);
 
119
        shaLine = shaBase + y * shaStride + (x >> FB_SHIFT);
 
120
        
 
121
        while (h--)
 
122
        {
 
123
            for (plane = 0; plane < 4; plane++)
 
124
            {
 
125
                width = w;
 
126
                scr = scrLine;
 
127
                sha = shaLine;
 
128
                winSize = 0;
 
129
                scrBase = 0;
 
130
                while (width) {
 
131
                    /* how much remains in this window */
 
132
                    i = scrBase + winSize - scr;
 
133
                    if (i <= 0 || scr < scrBase)
 
134
                    {
 
135
                        winBase = (CARD32 *) (*pBuf->window) (pScreen,
 
136
                                                              y,
 
137
                                                              (scr << 4) | (plane),
 
138
                                                              SHADOW_WINDOW_WRITE,
 
139
                                                              &winSize,
 
140
                                                              pBuf->closure);
 
141
                        if(!winBase)
 
142
                            return;
 
143
                        winSize >>= 2;
 
144
                        scrBase = scr;
 
145
                        i = winSize;
 
146
                    }
 
147
                    win = winBase + (scr - scrBase);
 
148
                    if (i > width)
 
149
                    i = width;
 
150
                    width -= i;
 
151
                    scr += i;
 
152
                   
 
153
                    while (i--)
 
154
                    {
 
155
                        GetBits(plane,0,s1);
 
156
                        GetBits(plane,2,s2);
 
157
                        GetBits(plane,4,s3);
 
158
                        GetBits(plane,6,s4);
 
159
                        *win++ = s1 | (s2 << 8) | (s3 << 16) | (s4 << 24);
 
160
                        sha += 8;
 
161
                    }
 
162
                }
 
163
            }
 
164
            shaLine += shaStride;
 
165
            y++;
 
166
        }
 
167
        pbox++;
 
168
    }
 
169
}
 
170