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

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/hw/xwin/winallpriv.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 (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
 
3
 *
 
4
 *Permission is hereby granted, free of charge, to any person obtaining
 
5
 * a copy of this software and associated documentation files (the
 
6
 *"Software"), to deal in the Software without restriction, including
 
7
 *without limitation the rights to use, copy, modify, merge, publish,
 
8
 *distribute, sublicense, and/or sell copies of the Software, and to
 
9
 *permit persons to whom the Software is furnished to do so, subject to
 
10
 *the following conditions:
 
11
 *
 
12
 *The above copyright notice and this permission notice shall be
 
13
 *included in all copies or substantial portions of the Software.
 
14
 *
 
15
 *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
16
 *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
17
 *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
18
 *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
 
19
 *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
 
20
 *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 
21
 *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
22
 *
 
23
 *Except as contained in this notice, the name of the XFree86 Project
 
24
 *shall not be used in advertising or otherwise to promote the sale, use
 
25
 *or other dealings in this Software without prior written authorization
 
26
 *from the XFree86 Project.
 
27
 *
 
28
 * Authors:     Keith Packard, MIT X Consortium
 
29
 *              Harold L Hunt II
 
30
 */
 
31
/* $XFree86: xc/programs/Xserver/hw/xwin/winallpriv.c,v 1.12 2002/10/31 23:04:39 alanh Exp $ */
 
32
 
 
33
#include "win.h"
 
34
 
 
35
 
 
36
 
 
37
/* See Porting Layer Definition - p. 58 */
 
38
/*
 
39
 * Allocate indexes for the privates that we use.
 
40
 * Allocate memory directly for the screen privates.
 
41
 * Reserve space in GCs and Pixmaps for our privates.
 
42
 * Colormap privates are handled in winAllocateCmapPrivates ()
 
43
 */
 
44
 
 
45
Bool
 
46
winAllocatePrivates (ScreenPtr pScreen)
 
47
{
 
48
  winPrivScreenPtr      pScreenPriv;
 
49
 
 
50
#if CYGDEBUG
 
51
  ErrorF ("winAllocateScreenPrivates - g_ulServerGeneration: %d "
 
52
          "serverGeneration: %d\n",
 
53
          g_ulServerGeneration, serverGeneration);
 
54
#endif
 
55
 
 
56
  /* We need a new slot for our privates if the screen gen has changed */
 
57
  if (g_ulServerGeneration != serverGeneration)
 
58
    {
 
59
      /* Get an index that we can store our privates at */
 
60
      g_iScreenPrivateIndex = AllocateScreenPrivateIndex ();
 
61
      g_iGCPrivateIndex = AllocateGCPrivateIndex ();
 
62
      g_iPixmapPrivateIndex = AllocatePixmapPrivateIndex ();
 
63
      g_iWindowPrivateIndex = AllocateWindowPrivateIndex ();
 
64
 
 
65
      g_ulServerGeneration = serverGeneration;
 
66
    }
 
67
 
 
68
  /* Allocate memory for the screen private structure */
 
69
  pScreenPriv = (winPrivScreenPtr) malloc (sizeof (winPrivScreenRec));
 
70
  if (!pScreenPriv)
 
71
    {
 
72
      ErrorF ("winAllocateScreenPrivates - malloc () failed\n");
 
73
      return FALSE;
 
74
    }
 
75
 
 
76
  /* Initialize the memory of the private structure */
 
77
  ZeroMemory (pScreenPriv, sizeof (winPrivScreenRec));
 
78
 
 
79
  /* Intialize private structure members */
 
80
  pScreenPriv->fActive = TRUE;
 
81
 
 
82
  /* Save the screen private pointer */
 
83
  winSetScreenPriv (pScreen, pScreenPriv);
 
84
 
 
85
  /* Reserve GC memory for our privates */
 
86
  if (!AllocateGCPrivate (pScreen, g_iGCPrivateIndex,
 
87
                          sizeof (winPrivGCRec)))
 
88
    {
 
89
      ErrorF ("winAllocatePrivates - AllocateGCPrivate () failed\n");
 
90
      return FALSE;
 
91
    }
 
92
 
 
93
  /* Reserve Pixmap memory for our privates */
 
94
  if (!AllocatePixmapPrivate (pScreen, g_iPixmapPrivateIndex,
 
95
                              sizeof (winPrivPixmapRec)))
 
96
    {
 
97
      ErrorF ("winAllocatePrivates - AllocatePixmapPrivates () failed\n");
 
98
      return FALSE;
 
99
    }
 
100
 
 
101
  /* Reserve Window memory for our privates */
 
102
  if (!AllocateWindowPrivate (pScreen, g_iWindowPrivateIndex,
 
103
                              sizeof (winPrivWinRec)))
 
104
    {
 
105
      ErrorF ("winAllocatePrivates () - AllocateWindowPrivates () failed\n");
 
106
       return FALSE;
 
107
     }
 
108
 
 
109
  return TRUE;
 
110
}
 
111
 
 
112
 
 
113
/*
 
114
 * Colormap privates may be allocated after the default colormap has
 
115
 * already been created for some screens.  This initialization procedure
 
116
 * is called for each default colormap that is found.
 
117
 */
 
118
 
 
119
Bool
 
120
winInitCmapPrivates (ColormapPtr pcmap)
 
121
{
 
122
#if CYGDEBUG
 
123
  ErrorF ("winInitCmapPrivates\n");
 
124
#endif
 
125
  
 
126
  /*
 
127
   * I see no way that this function can do anything useful
 
128
   * with only a ColormapPtr.  We don't have the index for
 
129
   * our dev privates yet, so we can't really initialize
 
130
   * anything.  Perhaps I am misunderstanding the purpose
 
131
   * of this function.
 
132
   */
 
133
  
 
134
  return TRUE;
 
135
}
 
136
 
 
137
 
 
138
/*
 
139
 * Allocate memory for our colormap privates
 
140
 */
 
141
 
 
142
Bool
 
143
winAllocateCmapPrivates (ColormapPtr pCmap)
 
144
{
 
145
  winPrivCmapPtr                pCmapPriv;
 
146
  static unsigned long          s_ulPrivateGeneration = 0;
 
147
 
 
148
#if CYGDEBUG
 
149
  ErrorF ("winAllocateCmapPrivates\n");
 
150
#endif
 
151
 
 
152
  /* Get a new privates index when the server generation changes */
 
153
  if (s_ulPrivateGeneration != serverGeneration)
 
154
    {
 
155
      /* Get an index that we can store our privates at */
 
156
      g_iCmapPrivateIndex = AllocateColormapPrivateIndex (winInitCmapPrivates);
 
157
      
 
158
      /* Save the new server generation */
 
159
      s_ulPrivateGeneration = serverGeneration;
 
160
    }
 
161
 
 
162
  /* Allocate memory for our private structure */
 
163
  pCmapPriv = (winPrivCmapPtr) malloc (sizeof (winPrivCmapRec));
 
164
  if (!pCmapPriv)
 
165
    {
 
166
      ErrorF ("winAllocateCmapPrivates - malloc () failed\n");
 
167
      return FALSE;
 
168
    }
 
169
 
 
170
  /* Initialize the memory of the private structure */
 
171
  ZeroMemory (pCmapPriv, sizeof (winPrivCmapRec));
 
172
 
 
173
  /* Save the cmap private pointer */
 
174
  winSetCmapPriv (pCmap, pCmapPriv);
 
175
 
 
176
#if CYGDEBUG
 
177
  ErrorF ("winAllocateCmapPrivates - Returning\n");
 
178
#endif
 
179
 
 
180
  return TRUE;
 
181
}