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

« back to all changes in this revision

Viewing changes to unix/xc/lib/PEX5/pl_escape.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: pl_escape.c,v 1.4 2001/02/09 02:03:27 xorgcvs Exp $ */
 
2
/*
 
3
 
 
4
Copyright 1992, 1998  The Open Group
 
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.
 
11
 
 
12
The above copyright notice and this permission notice shall be included
 
13
in all copies or substantial portions of the Software.
 
14
 
 
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 
16
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
17
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 
18
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
 
19
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 
20
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 
21
OTHER DEALINGS IN THE SOFTWARE.
 
22
 
 
23
Except as contained in this notice, the name of The Open Group shall
 
24
not be used in advertising or otherwise to promote the sale, use or
 
25
other dealings in this Software without prior written authorization
 
26
from The Open Group.
 
27
 
 
28
*/
 
29
 
 
30
#include "PEXlib.h"
 
31
#include "PEXlibint.h"
 
32
 
 
33
 
 
34
void
 
35
PEXEscape (display, escapeID, escapeDataSize, escapeData)
 
36
 
 
37
INPUT Display           *display;
 
38
INPUT unsigned long     escapeID;
 
39
INPUT int               escapeDataSize;
 
40
INPUT char              *escapeData;
 
41
 
 
42
{
 
43
    register pexEscapeReq       *req;
 
44
    char                        *pBuf;
 
45
 
 
46
 
 
47
    /*
 
48
     * Lock around the critical section, for multithreading.
 
49
     */
 
50
 
 
51
    LockDisplay (display);
 
52
 
 
53
 
 
54
    /*
 
55
     * Put the request in the X request buffer.
 
56
     */
 
57
 
 
58
    PEXGetReq (Escape, pBuf);
 
59
 
 
60
    BEGIN_REQUEST_HEADER (Escape, pBuf, req);
 
61
 
 
62
    PEXStoreReqExtraHead (Escape, escapeDataSize, req);
 
63
    req->escapeID = escapeID;
 
64
 
 
65
    END_REQUEST_HEADER (Escape, pBuf, req);
 
66
 
 
67
    Data (display, escapeData, escapeDataSize);
 
68
 
 
69
 
 
70
    /*
 
71
     * Done, so unlock and check for synchronous-ness.
 
72
     */
 
73
 
 
74
    UnlockDisplay (display);
 
75
    PEXSyncHandle (display);
 
76
}
 
77
 
 
78
 
 
79
char *
 
80
PEXEscapeWithReply (display, escapeID, escapeDataSize,
 
81
    escapeData, escapeOutDataSize)
 
82
 
 
83
INPUT Display           *display;
 
84
INPUT unsigned long     escapeID;
 
85
INPUT int               escapeDataSize;
 
86
INPUT char              *escapeData;
 
87
OUTPUT unsigned long    *escapeOutDataSize;
 
88
 
 
89
{
 
90
    register pexEscapeWithReplyReq      *req;
 
91
    char                                *pBuf;
 
92
    pexEscapeWithReplyReply             rep;
 
93
    char                                *escRepData;
 
94
    char                                *escRepDataRet;
 
95
 
 
96
 
 
97
    /*
 
98
     * Lock around the critical section, for multithreading.
 
99
     */
 
100
 
 
101
    LockDisplay (display);
 
102
 
 
103
 
 
104
    /*
 
105
     * Put the request in the X request buffer and get a reply.
 
106
     */
 
107
 
 
108
    PEXGetReq (EscapeWithReply, pBuf);
 
109
 
 
110
    BEGIN_REQUEST_HEADER (EscapeWithReply, pBuf, req);
 
111
 
 
112
    PEXStoreReqExtraHead (EscapeWithReply, escapeDataSize, req);
 
113
    req->escapeID = escapeID;
 
114
 
 
115
    END_REQUEST_HEADER (EscapeWithReply, pBuf, req);
 
116
 
 
117
    Data (display, escapeData, escapeDataSize);
 
118
 
 
119
    if (_XReply (display, (xReply *)&rep, 0, xFalse) == 0)
 
120
    {
 
121
        UnlockDisplay (display);
 
122
        PEXSyncHandle (display);
 
123
        *escapeOutDataSize = 0;
 
124
        return (NULL);               /* return an error */
 
125
    }
 
126
 
 
127
    *escapeOutDataSize = 20 + (rep.length << 2);
 
128
 
 
129
 
 
130
    /*
 
131
     * Allocate a buffer for the reply escape data
 
132
     */
 
133
 
 
134
    escRepData = escRepDataRet = Xmalloc ((unsigned) *escapeOutDataSize);
 
135
 
 
136
    memcpy (escRepData, rep.escape_specific, 20);
 
137
    escRepData += 20;
 
138
 
 
139
    if (rep.length)
 
140
        _XRead (display, (char *) escRepData, (long) (rep.length << 2));
 
141
 
 
142
 
 
143
    /*
 
144
     * Done, so unlock and check for synchronous-ness.
 
145
     */
 
146
 
 
147
    UnlockDisplay (display);
 
148
    PEXSyncHandle (display);
 
149
 
 
150
    return (escRepDataRet);
 
151
}
 
152
 
 
153
 
 
154
void PEXSetEchoColor (display, renderer, color_type, color)
 
155
 
 
156
INPUT Display           *display;
 
157
INPUT PEXRenderer       renderer;
 
158
INPUT int               color_type;
 
159
INPUT PEXColor          *color;
 
160
 
 
161
{
 
162
    char                        *escapeData;
 
163
    unsigned                    escapeSize;
 
164
    pexEscapeSetEchoColorData   *header;
 
165
    char                        *ptr;
 
166
    int                         fpConvert;
 
167
    int                         fpFormat;
 
168
 
 
169
 
 
170
    /*
 
171
     * Fill in the escape record.
 
172
     */
 
173
 
 
174
    escapeSize = SIZEOF (pexEscapeSetEchoColorData) +
 
175
        SIZEOF (pexColorSpecifier) + GetColorSize (color_type);
 
176
 
 
177
    escapeData = Xmalloc (escapeSize);
 
178
 
 
179
    fpFormat = PEXGetProtocolFloatFormat (display);
 
180
    fpConvert = (fpFormat != NATIVE_FP_FORMAT);
 
181
 
 
182
    header = (pexEscapeSetEchoColorData *) escapeData;
 
183
    header->fpFormat = fpFormat;
 
184
    header->rdr = renderer;
 
185
 
 
186
    ptr = escapeData + SIZEOF (pexEscapeSetEchoColorData);
 
187
    STORE_INT16 (color_type, ptr);
 
188
    ptr += 2;
 
189
    STORE_COLOR_VAL (color_type, (*color), ptr, fpConvert, fpFormat);
 
190
 
 
191
 
 
192
    /*
 
193
     * Generate the escape.
 
194
     */
 
195
 
 
196
    PEXEscape (display, PEXEscapeSetEchoColor, (int) escapeSize, escapeData);
 
197
 
 
198
    Xfree (escapeData);
 
199
}