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

« back to all changes in this revision

Viewing changes to unix/xc/lib/dps/Xlibnet.h

  • 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
/* $XConsortium: Xlibnet.h,v 1.18 91/07/23 19:01:27 rws Exp $ */
 
2
 
 
3
/*
 
4
Copyright 1991 Massachusetts Institute of Technology
 
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 M.I.T. not be used in advertising or
 
11
publicity pertaining to distribution of the software without specific,
 
12
written prior permission.  M.I.T. makes no representations about the
 
13
suitability of this software for any purpose.  It is provided "as is"
 
14
without express or implied warranty.
 
15
*/
 
16
/* $XFree86: xc/lib/dps/Xlibnet.h,v 1.7 2002/05/31 18:45:48 dawes Exp $ */
 
17
/*
 
18
 * Xlibnet.h - Xlib networking include files for UNIX Systems.
 
19
 */
 
20
 
 
21
#ifndef X_UNIX_PATH
 
22
#ifdef hpux
 
23
#define X_UNIX_PATH "/usr/spool/sockets/X11/"
 
24
#define OLD_UNIX_PATH "/tmp/.X11-unix/X"
 
25
#else
 
26
#define X_UNIX_PATH "/tmp/.X11-unix/X"
 
27
#endif
 
28
#endif /* X_UNIX_PATH */
 
29
 
 
30
#ifdef STREAMSCONN
 
31
#ifdef SYSV
 
32
/*
 
33
 * UNIX System V Release 3.2
 
34
 */
 
35
#define BytesReadable(fd,ptr) (_XBytesReadable ((fd), (ptr)))
 
36
#define MALLOC_0_RETURNS_NULL
 
37
#include <sys/ioctl.h>
 
38
 
 
39
#endif /* SYSV */
 
40
#ifdef SVR4
 
41
/*
 
42
 * TLI (Streams-based) networking
 
43
 */
 
44
#define BytesReadable(fd,ptr) (_XBytesReadable ((fd), (ptr)))
 
45
#include <sys/uio.h>            /* define struct iovec */
 
46
 
 
47
#endif /* SVR4 */
 
48
#else /* not STREAMSCONN */
 
49
/*
 
50
 * socket-based systems
 
51
 */
 
52
#include <netinet/in.h>
 
53
#include <sys/ioctl.h>
 
54
#include <netdb.h>
 
55
#include <sys/uio.h>    /* needed for XlibInt.c */
 
56
#ifdef SVR4
 
57
#include <sys/filio.h>
 
58
#endif
 
59
 
 
60
#if defined(i386) && defined(SYSV)
 
61
#if !defined(SCO) && !defined(SCO325)
 
62
#include <net/errno.h>
 
63
#endif
 
64
#include <sys/stropts.h>
 
65
#define BytesReadable(fd,ptr) ioctl((fd), I_NREAD, (ptr))
 
66
#else
 
67
#define BytesReadable(fd, ptr) ioctl ((fd), FIONREAD, (ptr))
 
68
#endif
 
69
 
 
70
#endif /* STREAMSCONN else */
 
71
 
 
72
/*
 
73
 * If your BytesReadable correctly detects broken connections, then
 
74
 * you should NOT define XCONN_CHECK_FREQ.
 
75
 */
 
76
#define XCONN_CHECK_FREQ 256
 
77
 
 
78
#ifndef X_NOT_POSIX
 
79
#ifdef _POSIX_SOURCE
 
80
#include <limits.h>
 
81
#else
 
82
#define _POSIX_SOURCE
 
83
#include <limits.h>
 
84
#undef _POSIX_SOURCE
 
85
#endif
 
86
#endif
 
87
#ifndef OPEN_MAX
 
88
#ifdef SVR4
 
89
#define OPEN_MAX 256
 
90
#else
 
91
#include <sys/param.h>
 
92
#ifndef OPEN_MAX
 
93
#ifdef NOFILE
 
94
#define OPEN_MAX NOFILE
 
95
#else
 
96
#if !defined(__UNIXOS2__) && !defined(__QNX__)
 
97
#define OPEN_MAX NOFILES_MAX
 
98
#else
 
99
#define OPEN_MAX 256
 
100
#endif
 
101
#endif
 
102
#endif
 
103
#endif
 
104
#endif
 
105
 
 
106
#if OPEN_MAX > 256
 
107
#undef OPEN_MAX
 
108
#define OPEN_MAX 256
 
109
#endif
 
110
 
 
111
/* Adobe additions */
 
112
#ifdef MSKCNT
 
113
#undef MSKCNT
 
114
#endif
 
115
#ifdef BITMASK
 
116
#undef BITMASK
 
117
#endif
 
118
#ifdef MASKIDX
 
119
#undef MASKIDX
 
120
#endif
 
121
 
 
122
#define MSKCNT ((OPEN_MAX + 31) / 32)
 
123
 
 
124
#if (MSKCNT==1)
 
125
#define BITMASK(i) (1 << (i))
 
126
#define MASKIDX(i) 0
 
127
#endif
 
128
#if (MSKCNT>1)
 
129
#define BITMASK(i) (1 << ((i) & 31))
 
130
#define MASKIDX(i) ((i) >> 5)
 
131
#endif
 
132
 
 
133
#define MASKWORD(buf, i) buf[MASKIDX(i)]
 
134
#define BITSET(buf, i) MASKWORD(buf, i) |= BITMASK(i)
 
135
#define BITCLEAR(buf, i) MASKWORD(buf, i) &= ~BITMASK(i)
 
136
#define GETBIT(buf, i) (MASKWORD(buf, i) & BITMASK(i))
 
137
 
 
138
/* Adobe additions */
 
139
#ifdef COPYBITS
 
140
#undef COPYBITS
 
141
#undef CLEARBITS 
 
142
#undef MASKANDSETBITS 
 
143
#undef ORBITS 
 
144
#undef UNSETBITS
 
145
#endif
 
146
 
 
147
#if (MSKCNT==1)
 
148
#define COPYBITS(src, dst) dst[0] = src[0]
 
149
#define CLEARBITS(buf) buf[0] = 0
 
150
#define MASKANDSETBITS(dst, b1, b2) dst[0] = (b1[0] & b2[0])
 
151
#define ORBITS(dst, b1, b2) dst[0] = (b1[0] | b2[0])
 
152
#define UNSETBITS(dst, b1) (dst[0] &= ~b1[0])
 
153
#define _XANYSET(src) (src[0])
 
154
#endif
 
155
#if (MSKCNT==2)
 
156
#define COPYBITS(src, dst) { dst[0] = src[0]; dst[1] = src[1]; }
 
157
#define CLEARBITS(buf) { buf[0] = 0; buf[1] = 0; }
 
158
#define MASKANDSETBITS(dst, b1, b2)  {\
 
159
                      dst[0] = (b1[0] & b2[0]);\
 
160
                      dst[1] = (b1[1] & b2[1]); }
 
161
#define ORBITS(dst, b1, b2)  {\
 
162
                      dst[0] = (b1[0] | b2[0]);\
 
163
                      dst[1] = (b1[1] | b2[1]); }
 
164
#define UNSETBITS(dst, b1) {\
 
165
                      dst[0] &= ~b1[0]; \
 
166
                      dst[1] &= ~b1[1]; }
 
167
#define _XANYSET(src) (src[0] || src[1])
 
168
#endif
 
169
#if (MSKCNT==3)
 
170
#define COPYBITS(src, dst) { dst[0] = src[0]; dst[1] = src[1]; \
 
171
                             dst[2] = src[2]; }
 
172
#define CLEARBITS(buf) { buf[0] = 0; buf[1] = 0; buf[2] = 0; }
 
173
#define MASKANDSETBITS(dst, b1, b2)  {\
 
174
                      dst[0] = (b1[0] & b2[0]);\
 
175
                      dst[1] = (b1[1] & b2[1]);\
 
176
                      dst[2] = (b1[2] & b2[2]); }
 
177
#define ORBITS(dst, b1, b2)  {\
 
178
                      dst[0] = (b1[0] | b2[0]);\
 
179
                      dst[1] = (b1[1] | b2[1]);\
 
180
                      dst[2] = (b1[2] | b2[2]); }
 
181
#define UNSETBITS(dst, b1) {\
 
182
                      dst[0] &= ~b1[0]; \
 
183
                      dst[1] &= ~b1[1]; \
 
184
                      dst[2] &= ~b1[2]; }
 
185
#define _XANYSET(src) (src[0] || src[1] || src[2])
 
186
#endif
 
187
#if (MSKCNT==4)
 
188
#define COPYBITS(src, dst) dst[0] = src[0]; dst[1] = src[1]; \
 
189
                           dst[2] = src[2]; dst[3] = src[3]
 
190
#define CLEARBITS(buf) buf[0] = 0; buf[1] = 0; buf[2] = 0; buf[3] = 0
 
191
#define MASKANDSETBITS(dst, b1, b2)  \
 
192
                      dst[0] = (b1[0] & b2[0]);\
 
193
                      dst[1] = (b1[1] & b2[1]);\
 
194
                      dst[2] = (b1[2] & b2[2]);\
 
195
                      dst[3] = (b1[3] & b2[3])
 
196
#define ORBITS(dst, b1, b2)  \
 
197
                      dst[0] = (b1[0] | b2[0]);\
 
198
                      dst[1] = (b1[1] | b2[1]);\
 
199
                      dst[2] = (b1[2] | b2[2]);\
 
200
                      dst[3] = (b1[3] | b2[3])
 
201
#define UNSETBITS(dst, b1) \
 
202
                      dst[0] &= ~b1[0]; \
 
203
                      dst[1] &= ~b1[1]; \
 
204
                      dst[2] &= ~b1[2]; \
 
205
                      dst[3] &= ~b1[3]
 
206
#define _XANYSET(src) (src[0] || src[1] || src[2] || src[3])
 
207
#endif
 
208
 
 
209
#if (MSKCNT>4)
 
210
#define COPYBITS(src, dst) bcopy((char *) src, (char *) dst,\
 
211
                                 MSKCNT*sizeof(long))
 
212
#define CLEARBITS(buf) bzero((char *) buf, MSKCNT*sizeof(long))
 
213
#define MASKANDSETBITS(dst, b1, b2)  \
 
214
                      { int cri;                        \
 
215
                        for (cri=MSKCNT; --cri>=0; )    \
 
216
                          dst[cri] = (b1[cri] & b2[cri]); }
 
217
#define ORBITS(dst, b1, b2)  \
 
218
                      { int cri;                        \
 
219
                      for (cri=MSKCNT; --cri>=0; )      \
 
220
                          dst[cri] = (b1[cri] | b2[cri]); }
 
221
#define UNSETBITS(dst, b1) \
 
222
                      { int cri;                        \
 
223
                      for (cri=MSKCNT; --cri>=0; )      \
 
224
                          dst[cri] &= ~b1[cri];  }
 
225
/*
 
226
 * If MSKCNT>4, then _XANYSET is a routine defined in XlibInt.c.
 
227
 *
 
228
 * #define _XANYSET(src) (src[0] || src[1] || src[2] || src[3] || src[4] ...)
 
229
 */
 
230
extern int N_XANYSET(unsigned long *);
 
231
#endif
 
232
 
 
233
/*
 
234
 *      ReadvFromServer and WritevToSever use struct iovec, normally found
 
235
 *      in Berkeley systems in <sys/uio.h>.  See the readv(2) and writev(2)
 
236
 *      manual pages for details.
 
237
 *
 
238
 *      struct iovec {
 
239
 *              caddr_t iov_base;
 
240
 *              int iov_len;
 
241
 *      };
 
242
 */
 
243
#if defined(USG) && !defined(CRAY) && !defined(umips) && !defined(MOTOROLA)
 
244
struct iovec {
 
245
    caddr_t iov_base;
 
246
    int iov_len;
 
247
};
 
248
#endif /* USG */
 
249
 
 
250
 
 
251
#ifdef STREAMSCONN
 
252
#include "Xstreams.h"
 
253
 
 
254
extern char _XsTypeOfStream[];
 
255
extern Xstream _XsStream[];
 
256
 
 
257
#define ReadFromServer(dpy, data, size) \
 
258
        (*_XsStream[_XsTypeOfStream[dpy]].ReadFromStream)((dpy), (data), (size), \
 
259
                                                     BUFFERING)
 
260
#define WriteToServer(dpy, bufind, size) \
 
261
        (*_XsStream[_XsTypeOfStream[dpy]].WriteToStream)((dpy), (bufind), (size))
 
262
 
 
263
#else /* else not STREAMSCONN */
 
264
 
 
265
/*
 
266
 * bsd can read from sockets directly
 
267
 */
 
268
#define ReadFromServer(dpy, data, size) read((dpy), (data), (size))
 
269
#define WriteToServer(dpy, bufind, size) write((dpy), (bufind), (size))
 
270
 
 
271
#endif /* STREAMSCONN */
 
272
 
 
273
 
 
274
#ifndef USL_COMPAT
 
275
#if !defined(USG) || defined(MOTOROLA)
 
276
#if (defined(SCO) || defined(SCO325)) || (!(defined(SYSV) && defined(i386)))
 
277
#define _XReadV readv
 
278
#endif
 
279
#define _XWriteV writev
 
280
#endif
 
281
#endif /* !USL_COMPAT */
 
282
 
 
283
#define ReadvFromServer(dpy, iov, iovcnt) _XReadV((dpy), (iov), (iovcnt))
 
284
#define WritevToServer(dpy, iov, iovcnt) _XWriteV((dpy), (iov), (iovcnt))