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

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/hw/xfree86/xaa/xaaFillArc.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
 * Copyright 1996  The XFree86 Project
 
3
 *
 
4
 * Permission is hereby granted, free of charge, to any person obtaining a 
 
5
 * copy of this software and associated documentation files (the "Software"), 
 
6
 * to deal in the Software without restriction, including without limitation 
 
7
 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 
 
8
 * and/or sell copies of the Software, and to permit persons to whom the 
 
9
 * Software is furnished to do so, subject to the following conditions:
 
10
 *
 
11
 * The above copyright notice and this permission notice shall be included in
 
12
 * all copies or substantial portions of the Software.
 
13
 * 
 
14
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
15
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
16
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL 
 
17
 * HARM HANEMAAYER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 
 
18
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 
 
19
 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
 
20
 * SOFTWARE.
 
21
 * 
 
22
 * Written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net).
 
23
 */
 
24
/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaFillArc.c,v 1.4 1999/05/30 03:03:31 dawes Exp $ */
 
25
 
 
26
/*
 
27
 * Filled solid arcs, based on cfbfillarc.c.
 
28
 *
 
29
 * Fill arc using calls to low-level span fill. Because the math for
 
30
 * each span can be done concurrently with the drawing of the span
 
31
 * with a graphics coprocessor operation, this is faster than just
 
32
 * using miPolyFillArc, which first calculates all the spans and then
 
33
 * calls FillSpans.
 
34
 *
 
35
 * Clipped arcs are dispatched to FillSpans.
 
36
 */
 
37
#include "misc.h"
 
38
#include "xf86.h"
 
39
#include "xf86_ansic.h"
 
40
#include "xf86_OSproc.h"
 
41
 
 
42
#include "X.h"
 
43
#include "scrnintstr.h"
 
44
#include "pixmapstr.h"
 
45
#include "xf86str.h"
 
46
#include "xaa.h"
 
47
#include "xaalocal.h"
 
48
#include "mifillarc.h"
 
49
#include "mi.h"
 
50
 
 
51
/*
 
52
 * This is based on the integer-math versions from mi. Perhaps on a
 
53
 * Pentium, the floating-point (double)-math version is faster.
 
54
 */
 
55
 
 
56
static void
 
57
XAAFillEllipseSolid(DrawablePtr pDraw, GCPtr pGC, xArc *arc)
 
58
{
 
59
    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
 
60
    register int x, y, e;
 
61
    int yk, xk, ym, xm, dx, dy, xorg, yorg;
 
62
    int slw;
 
63
    miFillArcRec info;
 
64
 
 
65
    (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu,
 
66
                pGC->planemask);
 
67
 
 
68
    miFillArcSetup(arc, &info);
 
69
    MIFILLARCSETUP();
 
70
    if (pGC->miTranslate)
 
71
    {
 
72
        xorg += pDraw->x;
 
73
        yorg += pDraw->y;
 
74
    }
 
75
    while (y > 0)
 
76
    {
 
77
        MIFILLARCSTEP(slw);
 
78
        if (slw > 0) {
 
79
            (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, xorg - x,
 
80
                    yorg - y, slw, 1);
 
81
            if (miFillArcLower(slw))
 
82
                (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn,
 
83
                        xorg - x, yorg + y + dy, slw, 1);
 
84
        }
 
85
    }
 
86
 
 
87
    SET_SYNC_FLAG(infoRec);
 
88
}
 
89
 
 
90
 
 
91
#define ADDSPAN(l,r) \
 
92
    if (r >= l) \
 
93
        (*infoRec->SubsequentSolidFillRect)( \
 
94
            infoRec->pScrn, l, ya, r - l + 1, 1);
 
95
 
 
96
#define ADDSLICESPANS(flip) \
 
97
    if (!flip) \
 
98
    { \
 
99
        ADDSPAN(xl, xr); \
 
100
    } \
 
101
    else \
 
102
    { \
 
103
        xc = xorg - x; \
 
104
        ADDSPAN(xc, xr); \
 
105
        xc += slw - 1; \
 
106
        ADDSPAN(xl, xc); \
 
107
    }
 
108
 
 
109
static void
 
110
XAAFillArcSliceSolid(DrawablePtr pDraw, GCPtr pGC, xArc *arc)
 
111
 
112
    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
 
113
    int yk, xk, ym, xm, dx, dy, xorg, yorg, slw;
 
114
    register int x, y, e;
 
115
    miFillArcRec info;
 
116
    miArcSliceRec slice;
 
117
    int ya, xl, xr, xc;
 
118
 
 
119
    (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu,
 
120
        pGC->planemask);
 
121
 
 
122
    miFillArcSetup(arc, &info);
 
123
    miFillArcSliceSetup(arc, &slice, pGC);
 
124
    MIFILLARCSETUP();
 
125
    slw = arc->height;
 
126
    if (slice.flip_top || slice.flip_bot)
 
127
        slw += (arc->height >> 1) + 1;
 
128
    if (pGC->miTranslate)
 
129
    {
 
130
        xorg += pDraw->x;
 
131
        yorg += pDraw->y;
 
132
        slice.edge1.x += pDraw->x;
 
133
        slice.edge2.x += pDraw->x;
 
134
    }
 
135
    while (y > 0)
 
136
    {
 
137
        MIFILLARCSTEP(slw);
 
138
        MIARCSLICESTEP(slice.edge1);
 
139
        MIARCSLICESTEP(slice.edge2);
 
140
        if (miFillSliceUpper(slice))
 
141
        {
 
142
            ya = yorg - y;
 
143
            MIARCSLICEUPPER(xl, xr, slice, slw);
 
144
            
 
145
            ADDSLICESPANS(slice.flip_top);
 
146
        }
 
147
        if (miFillSliceLower(slice))
 
148
        {
 
149
            ya = yorg + y + dy;
 
150
            MIARCSLICELOWER(xl, xr, slice, slw);
 
151
            ADDSLICESPANS(slice.flip_bot);
 
152
        }
 
153
    }
 
154
 
 
155
    SET_SYNC_FLAG(infoRec);
 
156
}
 
157
 
 
158
 
 
159
void
 
160
XAAPolyFillArcSolid(pDraw, pGC, narcs, parcs)
 
161
    DrawablePtr pDraw;
 
162
    GCPtr       pGC;
 
163
    int         narcs;
 
164
    xArc        *parcs;
 
165
{
 
166
    register xArc *arc;
 
167
    register int i;
 
168
    int x2, y2;
 
169
    BoxRec box;
 
170
    RegionPtr cclip;
 
171
 
 
172
    cclip = pGC->pCompositeClip;
 
173
 
 
174
    if(!REGION_NUM_RECTS(cclip))
 
175
        return;
 
176
 
 
177
    for (arc = parcs, i = narcs; --i >= 0; arc++)
 
178
    {
 
179
        if (miFillArcEmpty(arc))
 
180
            continue;
 
181
        if (miCanFillArc(arc))
 
182
        {
 
183
            box.x1 = arc->x + pDraw->x;
 
184
            box.y1 = arc->y + pDraw->y;
 
185
            /*
 
186
             * Because box.x2 and box.y2 get truncated to 16 bits, and the
 
187
             * RECT_IN_REGION test treats the resulting number as a signed
 
188
             * integer, the RECT_IN_REGION test alone can go the wrong way.
 
189
             * This can result in a server crash because the rendering
 
190
             * routines in this file deal directly with cpu addresses
 
191
             * of pixels to be stored, and do not clip or otherwise check
 
192
             * that all such addresses are within their respective pixmaps.
 
193
             * So we only allow the RECT_IN_REGION test to be used for
 
194
             * values that can be expressed correctly in a signed short.
 
195
             */
 
196
            x2 = box.x1 + (int)arc->width + 1;
 
197
            box.x2 = x2;
 
198
            y2 = box.y1 + (int)arc->height + 1;
 
199
            box.y2 = y2;
 
200
            if ( (x2 <= MAXSHORT) && (y2 <= MAXSHORT) &&
 
201
                    (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN) )
 
202
            {
 
203
                if ((arc->angle2 >= FULLCIRCLE) ||
 
204
                    (arc->angle2 <= -FULLCIRCLE))
 
205
                    XAAFillEllipseSolid(pDraw, pGC, arc);
 
206
                else
 
207
                    XAAFillArcSliceSolid(pDraw, pGC, arc);
 
208
                continue;
 
209
            }
 
210
        }
 
211
        miPolyFillArc(pDraw, pGC, 1, arc);
 
212
    }
 
213
}