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

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/hw/xnest/Pixmap.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
/* $Xorg: Pixmap.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
 
2
/*
 
3
 
 
4
Copyright 1993 by Davor Matic
 
5
 
 
6
Permission to use, copy, modify, distribute, and sell this software
 
7
and its documentation for any purpose is hereby granted without fee,
 
8
provided that the above copyright notice appear in all copies and that
 
9
both that copyright notice and this permission notice appear in
 
10
supporting documentation.  Davor Matic makes no representations about
 
11
the suitability of this software for any purpose.  It is provided "as
 
12
is" without express or implied warranty.
 
13
 
 
14
*/
 
15
/* $XFree86: xc/programs/Xserver/hw/xnest/Pixmap.c,v 3.6 2003/01/10 13:29:40 eich Exp $ */
 
16
 
 
17
#include "X.h"
 
18
#include "Xproto.h"
 
19
#include "miscstruct.h"
 
20
#include "pixmapstr.h"
 
21
#include "scrnintstr.h"
 
22
#include "regionstr.h"
 
23
#include "gc.h"
 
24
#include "servermd.h"
 
25
#include "mi.h"
 
26
 
 
27
#include "Xnest.h"
 
28
 
 
29
#include "Display.h"
 
30
#include "Screen.h"
 
31
#include "XNPixmap.h"
 
32
 
 
33
#ifdef PIXPRIV
 
34
int xnestPixmapPrivateIndex;        
 
35
#endif
 
36
 
 
37
PixmapPtr xnestCreatePixmap(pScreen, width, height, depth)
 
38
    ScreenPtr   pScreen;
 
39
    int         width;
 
40
    int         height;
 
41
    int         depth;
 
42
{
 
43
  PixmapPtr pPixmap;
 
44
 
 
45
  pPixmap = AllocatePixmap(pScreen, sizeof(xnestPrivPixmap));
 
46
  if (!pPixmap)
 
47
    return NullPixmap;
 
48
  pPixmap->drawable.type = DRAWABLE_PIXMAP;
 
49
  pPixmap->drawable.class = 0;
 
50
  pPixmap->drawable.depth = depth;
 
51
  pPixmap->drawable.bitsPerPixel = depth;
 
52
  pPixmap->drawable.id = 0;
 
53
  pPixmap->drawable.x = 0;
 
54
  pPixmap->drawable.y = 0;
 
55
  pPixmap->drawable.width = width;
 
56
  pPixmap->drawable.height = height;
 
57
  pPixmap->drawable.pScreen = pScreen;
 
58
  pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
 
59
  pPixmap->refcnt = 1;
 
60
  pPixmap->devKind = PixmapBytePad(width, depth);
 
61
#ifdef PIXPRIV
 
62
  pPixmap->devPrivates[xnestPixmapPrivateIndex].ptr =
 
63
      (pointer)((char *)pPixmap + pScreen->totalPixmapSize);
 
64
#else
 
65
  pPixmap->devPrivate.ptr = (pointer)(pPixmap + 1);
 
66
#endif
 
67
  if (width && height)
 
68
      xnestPixmapPriv(pPixmap)->pixmap = 
 
69
          XCreatePixmap(xnestDisplay, 
 
70
                        xnestDefaultWindows[pScreen->myNum],
 
71
                        width, height, depth);
 
72
  else
 
73
      xnestPixmapPriv(pPixmap)->pixmap = 0;
 
74
  
 
75
  return pPixmap;
 
76
}
 
77
 
 
78
Bool xnestDestroyPixmap(pPixmap)
 
79
     PixmapPtr pPixmap;
 
80
{
 
81
  if(--pPixmap->refcnt)
 
82
    return TRUE;
 
83
  XFreePixmap(xnestDisplay, xnestPixmap(pPixmap));
 
84
  xfree(pPixmap);
 
85
  return TRUE;
 
86
}
 
87
 
 
88
RegionPtr xnestPixmapToRegion(pPixmap)
 
89
     PixmapPtr pPixmap;
 
90
{
 
91
  XImage *ximage;
 
92
  register RegionPtr pReg, pTmpReg;
 
93
  register int x, y;
 
94
  unsigned long previousPixel, currentPixel;
 
95
  BoxRec Box;
 
96
  Bool overlap;
 
97
  
 
98
  ximage = XGetImage(xnestDisplay, xnestPixmap(pPixmap), 0, 0,
 
99
                     pPixmap->drawable.width, pPixmap->drawable.height,
 
100
                     1, XYPixmap);
 
101
  
 
102
  pReg = REGION_CREATE(pPixmap->drawable.pScreen, NULL, 1);
 
103
  pTmpReg = REGION_CREATE(pPixmap->drawable.pScreen, NULL, 1);
 
104
  if(!pReg || !pTmpReg) return NullRegion;
 
105
  
 
106
  for (y = 0; y < pPixmap->drawable.height; y++) {
 
107
    Box.y1 = y;
 
108
    Box.y2 = y + 1;
 
109
    previousPixel = 0L;
 
110
    for (x = 0; x < pPixmap->drawable.width; x++) {
 
111
      currentPixel = XGetPixel(ximage, x, y);
 
112
      if (previousPixel != currentPixel) {
 
113
        if (previousPixel == 0L) { 
 
114
          /* left edge */
 
115
          Box.x1 = x;
 
116
        }
 
117
        else if (currentPixel == 0L) {
 
118
          /* right edge */
 
119
          Box.x2 = x;
 
120
          REGION_RESET(pPixmap->drawable.pScreen, pTmpReg, &Box);
 
121
          REGION_APPEND(pPixmap->drawable.pScreen, pReg, pTmpReg);
 
122
        }
 
123
        previousPixel = currentPixel;
 
124
      }
 
125
    }
 
126
    if (previousPixel != 0L) {
 
127
      /* right edge because of the end of pixmap */
 
128
      Box.x2 = pPixmap->drawable.width;
 
129
      REGION_RESET(pPixmap->drawable.pScreen, pTmpReg, &Box);
 
130
      REGION_APPEND(pPixmap->drawable.pScreen, pReg, pTmpReg);
 
131
    }
 
132
  }
 
133
  
 
134
  REGION_DESTROY(pPixmap->drawable.pScreen, pTmpReg);
 
135
  XDestroyImage(ximage);
 
136
 
 
137
  REGION_VALIDATE(pPixmap->drawable.pScreen, pReg, &overlap);
 
138
 
 
139
  return(pReg);
 
140
}