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

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/fb/fbsolid.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/fb/fbsolid.c,v 1.8 2001/10/28 03:33:08 tsi Exp $
 
3
 *
 
4
 * Copyright � 1998 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
#define FbSelectPart(xor,o,t)    xor
 
26
 
 
27
#include "fb.h"
 
28
 
 
29
void
 
30
fbSolid (FbBits     *dst,
 
31
         FbStride   dstStride,
 
32
         int        dstX,
 
33
         int        bpp,
 
34
 
 
35
         int        width,
 
36
         int        height,
 
37
 
 
38
         FbBits     and,
 
39
         FbBits     xor)
 
40
{
 
41
    FbBits  startmask, endmask;
 
42
    int     n, nmiddle;
 
43
    int     startbyte, endbyte;
 
44
 
 
45
#ifdef FB_24BIT
 
46
    if (bpp == 24 && (!FbCheck24Pix(and) || !FbCheck24Pix(xor)))
 
47
    {
 
48
        fbSolid24 (dst, dstStride, dstX, width, height, and, xor);
 
49
        return;
 
50
    }
 
51
#endif
 
52
        
 
53
    dst += dstX >> FB_SHIFT;
 
54
    dstX &= FB_MASK;
 
55
    FbMaskBitsBytes(dstX, width, and == 0, startmask, startbyte, 
 
56
                    nmiddle, endmask, endbyte);
 
57
    if (startmask)
 
58
        dstStride--;
 
59
    dstStride -= nmiddle;
 
60
    while (height--)
 
61
    {
 
62
        if (startmask)
 
63
        {
 
64
            FbDoLeftMaskByteRRop(dst,startbyte,startmask,and,xor);
 
65
            dst++;
 
66
        }
 
67
        n = nmiddle;
 
68
        if (!and)
 
69
            while (n--)
 
70
                *dst++ = xor;
 
71
        else
 
72
            while (n--)
 
73
            {
 
74
                *dst = FbDoRRop (*dst, and, xor);
 
75
                dst++;
 
76
            }
 
77
        if (endmask)
 
78
            FbDoRightMaskByteRRop(dst,endbyte,endmask,and,xor);
 
79
        dst += dstStride;
 
80
    }
 
81
}
 
82
 
 
83
#ifdef FB_24BIT
 
84
void
 
85
fbSolid24 (FbBits   *dst,
 
86
           FbStride dstStride,
 
87
           int      dstX,
 
88
 
 
89
           int      width,
 
90
           int      height,
 
91
 
 
92
           FbBits   and,
 
93
           FbBits   xor)
 
94
{
 
95
    FbBits  startmask, endmask;
 
96
    FbBits  xor0 = 0, xor1 = 0, xor2 = 0;
 
97
    FbBits  and0 = 0, and1 = 0, and2 = 0;
 
98
    FbBits  xorS = 0, andS = 0, xorE = 0, andE = 0;
 
99
    int     n, nmiddle;
 
100
    int     rotS, rot;
 
101
 
 
102
    dst += dstX >> FB_SHIFT;
 
103
    dstX &= FB_MASK;
 
104
    /*
 
105
     * Rotate pixel values this far across the word to align on
 
106
     * screen pixel boundaries
 
107
     */
 
108
    rot = FbFirst24Rot (dstX);
 
109
    FbMaskBits (dstX, width, startmask, nmiddle, endmask);
 
110
    if (startmask)
 
111
        dstStride--;
 
112
    dstStride -= nmiddle;
 
113
    
 
114
    /*
 
115
     * Precompute rotated versions of the rasterop values
 
116
     */
 
117
    rotS = rot;
 
118
    xor = FbRot24(xor,rotS);
 
119
    and = FbRot24(and,rotS);
 
120
    if (startmask)
 
121
    {
 
122
        xorS = xor;
 
123
        andS = and;
 
124
        xor = FbNext24Pix(xor);
 
125
        and = FbNext24Pix(and);
 
126
    }
 
127
    
 
128
    if (nmiddle)
 
129
    {
 
130
        xor0 = xor;
 
131
        and0 = and;
 
132
        xor1 = FbNext24Pix(xor0);
 
133
        and1 = FbNext24Pix(and0);
 
134
        xor2 = FbNext24Pix(xor1);
 
135
        and2 = FbNext24Pix(and1);
 
136
    }
 
137
    
 
138
    if (endmask)
 
139
    {
 
140
        switch (nmiddle % 3) {
 
141
        case 0:
 
142
            xorE = xor;
 
143
            andE = and;
 
144
            break;
 
145
        case 1:
 
146
            xorE = xor1;
 
147
            andE = and1;
 
148
            break;
 
149
        case 2:
 
150
            xorE = xor2;
 
151
            andE = and2;
 
152
            break;
 
153
        }
 
154
    }
 
155
    
 
156
    while (height--)
 
157
    {
 
158
        if (startmask)
 
159
        {
 
160
            *dst = FbDoMaskRRop(*dst, andS, xorS, startmask);
 
161
            dst++;
 
162
        }
 
163
        n = nmiddle;
 
164
        if (!and0)
 
165
        {
 
166
            while (n >= 3)
 
167
            {
 
168
                *dst++ = xor0;
 
169
                *dst++ = xor1;
 
170
                *dst++ = xor2;
 
171
                n -= 3;
 
172
            }
 
173
            if (n)
 
174
            {
 
175
                *dst++ = xor0;
 
176
                n--;
 
177
                if (n)
 
178
                {
 
179
                    *dst++ = xor1;
 
180
                }
 
181
            }
 
182
        }
 
183
        else
 
184
        {
 
185
            while (n >= 3)
 
186
            {
 
187
                *dst = FbDoRRop (*dst, and0, xor0);
 
188
                dst++;
 
189
                *dst = FbDoRRop (*dst, and1, xor1);
 
190
                dst++;
 
191
                *dst = FbDoRRop (*dst, and2, xor2);
 
192
                dst++;
 
193
                n -= 3;
 
194
            }
 
195
            if (n)
 
196
            {
 
197
                *dst = FbDoRRop (*dst, and0, xor0);
 
198
                dst++;
 
199
                n--;
 
200
                if (n)
 
201
                {
 
202
                    *dst = FbDoRRop (*dst, and1, xor1);
 
203
                    dst++;
 
204
                }
 
205
            }
 
206
        }
 
207
        if (endmask)
 
208
            *dst = FbDoMaskRRop (*dst, andE, xorE, endmask);
 
209
        dst += dstStride;
 
210
    }
 
211
}
 
212
#endif