port to xorg-server 1.10: -- Log Message: apply https://cgit.freedesktop.org/xorg/xserver/commit/?id=2855f759b1e7bf7f5e57cac36c1f0d0e5ac1a683 auth: remove AuthToIDFunc and associated functions. Not used anymore. And the current code for MitToId has a use-after-free() issue. [Also remove the actual implementations - ajax] Signed-off-by: Matthieu Herrb <matthieu@herrb.eu> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> --diff -r1.1.1.1 -r1.2 xsrc/external/mit/xorg-server.old/dist/os/auth.c
(mrg)
--- xsrc/external/mit/xorg-server.old/dist/os/auth.c 2016/06/09 09:08:00 1.1.1.1
+++ xsrc/external/mit/xorg-server.old/dist/os/auth.c 2017/03/08 07:18:47 1.2
@@ -42,55 +42,54 @@ from The Open Group. | @@ -42,55 +42,54 @@ from The Open Group. | |||
42 | # include "dixstruct.h" | 42 | # include "dixstruct.h" | |
43 | # include <sys/types.h> | 43 | # include <sys/types.h> | |
44 | # include <sys/stat.h> | 44 | # include <sys/stat.h> | |
45 | #ifdef WIN32 | 45 | #ifdef WIN32 | |
46 | #include <X11/Xw32defs.h> | 46 | #include <X11/Xw32defs.h> | |
47 | #endif | 47 | #endif | |
48 | 48 | |||
49 | struct protocol { | 49 | struct protocol { | |
50 | unsigned short name_length; | 50 | unsigned short name_length; | |
51 | char *name; | 51 | char *name; | |
52 | AuthAddCFunc Add; /* new authorization data */ | 52 | AuthAddCFunc Add; /* new authorization data */ | |
53 | AuthCheckFunc Check; /* verify client authorization data */ | 53 | AuthCheckFunc Check; /* verify client authorization data */ | |
54 | AuthRstCFunc Reset; /* delete all authorization data entries */ | 54 | AuthRstCFunc Reset; /* delete all authorization data entries */ | |
55 | AuthToIDFunc ToID; /* convert cookie to ID */ | |||
56 | AuthFromIDFunc FromID; /* convert ID to cookie */ | 55 | AuthFromIDFunc FromID; /* convert ID to cookie */ | |
57 | AuthRemCFunc Remove; /* remove a specific cookie */ | 56 | AuthRemCFunc Remove; /* remove a specific cookie */ | |
58 | #ifdef XCSECURITY | 57 | #ifdef XCSECURITY | |
59 | AuthGenCFunc Generate; | 58 | AuthGenCFunc Generate; | |
60 | #endif | 59 | #endif | |
61 | }; | 60 | }; | |
62 | 61 | |||
63 | static struct protocol protocols[] = { | 62 | static struct protocol protocols[] = { | |
64 | { (unsigned short) 18, "MIT-MAGIC-COOKIE-1", | 63 | { (unsigned short) 18, "MIT-MAGIC-COOKIE-1", | |
65 | MitAddCookie, MitCheckCookie, MitResetCookie, | 64 | MitAddCookie, MitCheckCookie, MitResetCookie, | |
66 | MitToID, MitFromID, MitRemoveCookie, | 65 | MitFromID, MitRemoveCookie, | |
67 | #ifdef XCSECURITY | 66 | #ifdef XCSECURITY | |
68 | MitGenerateCookie | 67 | MitGenerateCookie | |
69 | #endif | 68 | #endif | |
70 | }, | 69 | }, | |
71 | #ifdef HASXDMAUTH | 70 | #ifdef HASXDMAUTH | |
72 | { (unsigned short) 19, "XDM-AUTHORIZATION-1", | 71 | { (unsigned short) 19, "XDM-AUTHORIZATION-1", | |
73 | XdmAddCookie, XdmCheckCookie, XdmResetCookie, | 72 | XdmAddCookie, XdmCheckCookie, XdmResetCookie, | |
74 | XdmToID, XdmFromID, XdmRemoveCookie, | 73 | XdmFromID, XdmRemoveCookie, | |
75 | #ifdef XCSECURITY | 74 | #ifdef XCSECURITY | |
76 | NULL | 75 | NULL | |
77 | #endif | 76 | #endif | |
78 | }, | 77 | }, | |
79 | #endif | 78 | #endif | |
80 | #ifdef SECURE_RPC | 79 | #ifdef SECURE_RPC | |
81 | { (unsigned short) 9, "SUN-DES-1", | 80 | { (unsigned short) 9, "SUN-DES-1", | |
82 | SecureRPCAdd, SecureRPCCheck, SecureRPCReset, | 81 | SecureRPCAdd, SecureRPCCheck, SecureRPCReset, | |
83 | SecureRPCToID, SecureRPCFromID,SecureRPCRemove, | 82 | SecureRPCFromID,SecureRPCRemove, | |
84 | #ifdef XCSECURITY | 83 | #ifdef XCSECURITY | |
85 | NULL | 84 | NULL | |
86 | #endif | 85 | #endif | |
87 | }, | 86 | }, | |
88 | #endif | 87 | #endif | |
89 | }; | 88 | }; | |
90 | 89 | |||
91 | # define NUM_AUTHORIZATION (sizeof (protocols) /\ | 90 | # define NUM_AUTHORIZATION (sizeof (protocols) /\ | |
92 | sizeof (struct protocol)) | 91 | sizeof (struct protocol)) | |
93 | 92 | |||
94 | /* | 93 | /* | |
95 | * Initialize all classes of authorization by reading the | 94 | * Initialize all classes of authorization by reading the | |
96 | * specified authorization file | 95 | * specified authorization file |
--- xsrc/external/mit/xorg-server.old/dist/os/mitauth.c 2016/06/09 09:08:00 1.1.1.1
+++ xsrc/external/mit/xorg-server.old/dist/os/mitauth.c 2017/03/08 07:18:47 1.2
@@ -93,41 +93,26 @@ int | @@ -93,41 +93,26 @@ int | |||
93 | MitResetCookie (void) | 93 | MitResetCookie (void) | |
94 | { | 94 | { | |
95 | struct auth *auth, *next; | 95 | struct auth *auth, *next; | |
96 | 96 | |||
97 | for (auth = mit_auth; auth; auth=next) { | 97 | for (auth = mit_auth; auth; auth=next) { | |
98 | next = auth->next; | 98 | next = auth->next; | |
99 | free(auth->data); | 99 | free(auth->data); | |
100 | free(auth); | 100 | free(auth); | |
101 | } | 101 | } | |
102 | mit_auth = 0; | 102 | mit_auth = 0; | |
103 | return 0; | 103 | return 0; | |
104 | } | 104 | } | |
105 | 105 | |||
106 | XID | |||
107 | MitToID ( | |||
108 | unsigned short data_length, | |||
109 | char *data) | |||
110 | { | |||
111 | struct auth *auth; | |||
112 | ||||
113 | for (auth = mit_auth; auth; auth=auth->next) { | |||
114 | if (data_length == auth->len && | |||
115 | memcmp (data, auth->data, data_length) == 0) | |||
116 | return auth->id; | |||
117 | } | |||
118 | return (XID) -1; | |||
119 | } | |||
120 | ||||
121 | int | 106 | int | |
122 | MitFromID ( | 107 | MitFromID ( | |
123 | XID id, | 108 | XID id, | |
124 | unsigned short *data_lenp, | 109 | unsigned short *data_lenp, | |
125 | char **datap) | 110 | char **datap) | |
126 | { | 111 | { | |
127 | struct auth *auth; | 112 | struct auth *auth; | |
128 | 113 | |||
129 | for (auth = mit_auth; auth; auth=auth->next) { | 114 | for (auth = mit_auth; auth; auth=auth->next) { | |
130 | if (id == auth->id) { | 115 | if (id == auth->id) { | |
131 | *data_lenp = auth->len; | 116 | *data_lenp = auth->len; | |
132 | *datap = auth->data; | 117 | *datap = auth->data; | |
133 | return 1; | 118 | return 1; |
--- xsrc/external/mit/xorg-server.old/dist/os/osdep.h 2016/06/09 09:08:01 1.1.1.1
+++ xsrc/external/mit/xorg-server.old/dist/os/osdep.h 2017/03/08 07:18:47 1.2
@@ -148,29 +148,26 @@ typedef XID (*AuthCheckFunc) (AuthCheckA | @@ -148,29 +148,26 @@ typedef XID (*AuthCheckFunc) (AuthCheckA | |||
148 | 148 | |||
149 | #define AuthFromIDArgs XID id, unsigned short *data_lenp, char **datap | 149 | #define AuthFromIDArgs XID id, unsigned short *data_lenp, char **datap | |
150 | typedef int (*AuthFromIDFunc) (AuthFromIDArgs); | 150 | typedef int (*AuthFromIDFunc) (AuthFromIDArgs); | |
151 | 151 | |||
152 | #define AuthGenCArgs unsigned data_length, const char *data, XID id, unsigned *data_length_return, char **data_return | 152 | #define AuthGenCArgs unsigned data_length, const char *data, XID id, unsigned *data_length_return, char **data_return | |
153 | typedef XID (*AuthGenCFunc) (AuthGenCArgs); | 153 | typedef XID (*AuthGenCFunc) (AuthGenCArgs); | |
154 | 154 | |||
155 | #define AuthRemCArgs unsigned short data_length, const char *data | 155 | #define AuthRemCArgs unsigned short data_length, const char *data | |
156 | typedef int (*AuthRemCFunc) (AuthRemCArgs); | 156 | typedef int (*AuthRemCFunc) (AuthRemCArgs); | |
157 | 157 | |||
158 | #define AuthRstCArgs void | 158 | #define AuthRstCArgs void | |
159 | typedef int (*AuthRstCFunc) (AuthRstCArgs); | 159 | typedef int (*AuthRstCFunc) (AuthRstCArgs); | |
160 | 160 | |||
161 | #define AuthToIDArgs unsigned short data_length, char *data | |||
162 | typedef XID (*AuthToIDFunc) (AuthToIDArgs); | |||
163 | ||||
164 | typedef void (*OsCloseFunc)(ClientPtr); | 161 | typedef void (*OsCloseFunc)(ClientPtr); | |
165 | 162 | |||
166 | typedef int (*OsFlushFunc)(ClientPtr who, struct _osComm * oc, char* extraBuf, int extraCount); | 163 | typedef int (*OsFlushFunc)(ClientPtr who, struct _osComm * oc, char* extraBuf, int extraCount); | |
167 | 164 | |||
168 | typedef struct _osComm { | 165 | typedef struct _osComm { | |
169 | int fd; | 166 | int fd; | |
170 | ConnectionInputPtr input; | 167 | ConnectionInputPtr input; | |
171 | ConnectionOutputPtr output; | 168 | ConnectionOutputPtr output; | |
172 | XID auth_id; /* authorization id */ | 169 | XID auth_id; /* authorization id */ | |
173 | CARD32 conn_time; /* timestamp if not established, else 0 */ | 170 | CARD32 conn_time; /* timestamp if not established, else 0 */ | |
174 | struct _XtransConnInfo *trans_conn; /* transport connection object */ | 171 | struct _XtransConnInfo *trans_conn; /* transport connection object */ | |
175 | Bool local_client; | 172 | Bool local_client; | |
176 | } OsCommRec, *OsCommPtr; | 173 | } OsCommRec, *OsCommPtr; | |
@@ -217,47 +214,44 @@ typedef long int fd_mask; | @@ -217,47 +214,44 @@ typedef long int fd_mask; | |||
217 | #endif | 214 | #endif | |
218 | #define ffs mffs | 215 | #define ffs mffs | |
219 | extern int mffs(fd_mask); | 216 | extern int mffs(fd_mask); | |
220 | 217 | |||
221 | /* in access.c */ | 218 | /* in access.c */ | |
222 | extern Bool ComputeLocalClient(ClientPtr client); | 219 | extern Bool ComputeLocalClient(ClientPtr client); | |
223 | 220 | |||
224 | /* in auth.c */ | 221 | /* in auth.c */ | |
225 | extern void GenerateRandomData (int len, char *buf); | 222 | extern void GenerateRandomData (int len, char *buf); | |
226 | 223 | |||
227 | /* in mitauth.c */ | 224 | /* in mitauth.c */ | |
228 | extern XID MitCheckCookie (AuthCheckArgs); | 225 | extern XID MitCheckCookie (AuthCheckArgs); | |
229 | extern XID MitGenerateCookie (AuthGenCArgs); | 226 | extern XID MitGenerateCookie (AuthGenCArgs); | |
230 | extern XID MitToID (AuthToIDArgs); | |||
231 | extern int MitAddCookie (AuthAddCArgs); | 227 | extern int MitAddCookie (AuthAddCArgs); | |
232 | extern int MitFromID (AuthFromIDArgs); | 228 | extern int MitFromID (AuthFromIDArgs); | |
233 | extern int MitRemoveCookie (AuthRemCArgs); | 229 | extern int MitRemoveCookie (AuthRemCArgs); | |
234 | extern int MitResetCookie (AuthRstCArgs); | 230 | extern int MitResetCookie (AuthRstCArgs); | |
235 | 231 | |||
236 | /* in xdmauth.c */ | 232 | /* in xdmauth.c */ | |
237 | #ifdef HASXDMAUTH | 233 | #ifdef HASXDMAUTH | |
238 | extern XID XdmCheckCookie (AuthCheckArgs); | 234 | extern XID XdmCheckCookie (AuthCheckArgs); | |
239 | extern XID XdmToID (AuthToIDArgs); | |||
240 | extern int XdmAddCookie (AuthAddCArgs); | 235 | extern int XdmAddCookie (AuthAddCArgs); | |
241 | extern int XdmFromID (AuthFromIDArgs); | 236 | extern int XdmFromID (AuthFromIDArgs); | |
242 | extern int XdmRemoveCookie (AuthRemCArgs); | 237 | extern int XdmRemoveCookie (AuthRemCArgs); | |
243 | extern int XdmResetCookie (AuthRstCArgs); | 238 | extern int XdmResetCookie (AuthRstCArgs); | |
244 | #endif | 239 | #endif | |
245 | 240 | |||
246 | /* in rpcauth.c */ | 241 | /* in rpcauth.c */ | |
247 | #ifdef SECURE_RPC | 242 | #ifdef SECURE_RPC | |
248 | extern void SecureRPCInit (AuthInitArgs); | 243 | extern void SecureRPCInit (AuthInitArgs); | |
249 | extern XID SecureRPCCheck (AuthCheckArgs); | 244 | extern XID SecureRPCCheck (AuthCheckArgs); | |
250 | extern XID SecureRPCToID (AuthToIDArgs); | |||
251 | extern int SecureRPCAdd (AuthAddCArgs); | 245 | extern int SecureRPCAdd (AuthAddCArgs); | |
252 | extern int SecureRPCFromID (AuthFromIDArgs); | 246 | extern int SecureRPCFromID (AuthFromIDArgs); | |
253 | extern int SecureRPCRemove (AuthRemCArgs); | 247 | extern int SecureRPCRemove (AuthRemCArgs); | |
254 | extern int SecureRPCReset (AuthRstCArgs); | 248 | extern int SecureRPCReset (AuthRstCArgs); | |
255 | #endif | 249 | #endif | |
256 | 250 | |||
257 | #ifdef XDMCP | 251 | #ifdef XDMCP | |
258 | /* in xdmcp.c */ | 252 | /* in xdmcp.c */ | |
259 | extern void XdmcpUseMsg (void); | 253 | extern void XdmcpUseMsg (void); | |
260 | extern int XdmcpOptions(int argc, char **argv, int i); | 254 | extern int XdmcpOptions(int argc, char **argv, int i); | |
261 | extern void XdmcpRegisterConnection ( | 255 | extern void XdmcpRegisterConnection ( | |
262 | int type, | 256 | int type, | |
263 | const char *address, | 257 | const char *address, |
--- xsrc/external/mit/xorg-server.old/dist/os/rpcauth.c 2016/06/09 09:08:01 1.1.1.1
+++ xsrc/external/mit/xorg-server.old/dist/os/rpcauth.c 2017/03/08 07:18:47 1.2
@@ -167,31 +167,25 @@ SecureRPCAdd (unsigned short data_length | @@ -167,31 +167,25 @@ SecureRPCAdd (unsigned short data_length | |||
167 | if (data_length) | 167 | if (data_length) | |
168 | AddHost ((pointer) 0, FamilyNetname, data_length, data); | 168 | AddHost ((pointer) 0, FamilyNetname, data_length, data); | |
169 | rpc_id = id; | 169 | rpc_id = id; | |
170 | return 1; | 170 | return 1; | |
171 | } | 171 | } | |
172 | 172 | |||
173 | _X_HIDDEN int | 173 | _X_HIDDEN int | |
174 | SecureRPCReset (void) | 174 | SecureRPCReset (void) | |
175 | { | 175 | { | |
176 | rpc_id = (XID) ~0L; | 176 | rpc_id = (XID) ~0L; | |
177 | return 1; | 177 | return 1; | |
178 | } | 178 | } | |
179 | 179 | |||
180 | _X_HIDDEN XID | |||
181 | SecureRPCToID (unsigned short data_length, char *data) | |||
182 | { | |||
183 | return rpc_id; | |||
184 | } | |||
185 | ||||
186 | _X_HIDDEN int | 180 | _X_HIDDEN int | |
187 | SecureRPCFromID (XID id, unsigned short *data_lenp, char **datap) | 181 | SecureRPCFromID (XID id, unsigned short *data_lenp, char **datap) | |
188 | { | 182 | { | |
189 | return 0; | 183 | return 0; | |
190 | } | 184 | } | |
191 | 185 | |||
192 | _X_HIDDEN int | 186 | _X_HIDDEN int | |
193 | SecureRPCRemove (unsigned short data_length, const char *data) | 187 | SecureRPCRemove (unsigned short data_length, const char *data) | |
194 | { | 188 | { | |
195 | return 0; | 189 | return 0; | |
196 | } | 190 | } | |
197 | #endif /* SECURE_RPC */ | 191 | #endif /* SECURE_RPC */ |
--- xsrc/external/mit/xorg-server.old/dist/os/xdmauth.c 2016/06/09 09:08:00 1.1.1.1
+++ xsrc/external/mit/xorg-server.old/dist/os/xdmauth.c 2017/03/08 07:18:47 1.2
@@ -413,51 +413,26 @@ XdmResetCookie (void) | @@ -413,51 +413,26 @@ XdmResetCookie (void) | |||
413 | next_auth = auth->next; | 413 | next_auth = auth->next; | |
414 | free(auth); | 414 | free(auth); | |
415 | } | 415 | } | |
416 | xdmAuth = 0; | 416 | xdmAuth = 0; | |
417 | for (client = xdmClients; client; client=next_client) | 417 | for (client = xdmClients; client; client=next_client) | |
418 | { | 418 | { | |
419 | next_client = client->next; | 419 | next_client = client->next; | |
420 | free(client); | 420 | free(client); | |
421 | } | 421 | } | |
422 | xdmClients = (XdmClientAuthPtr) 0; | 422 | xdmClients = (XdmClientAuthPtr) 0; | |
423 | return 1; | 423 | return 1; | |
424 | } | 424 | } | |
425 | 425 | |||
426 | XID | |||
427 | XdmToID (unsigned short cookie_length, char *cookie) | |||
428 | { | |||
429 | XdmAuthorizationPtr auth; | |||
430 | XdmClientAuthPtr client; | |||
431 | unsigned char *plain; | |||
432 | ||||
433 | plain = malloc(cookie_length); | |||
434 | if (!plain) | |||
435 | return (XID) -1; | |||
436 | for (auth = xdmAuth; auth; auth=auth->next) { | |||
437 | XdmcpUnwrap ((unsigned char *)cookie, (unsigned char *)&auth->key, plain, cookie_length); | |||
438 | if ((client = XdmAuthorizationValidate (plain, cookie_length, &auth->rho, NULL, NULL)) != NULL) | |||
439 | { | |||
440 | free(client); | |||
441 | free(cookie); | |||
442 | free(plain); | |||
443 | return auth->id; | |||
444 | } | |||
445 | } | |||
446 | free(cookie); | |||
447 | free(plain); | |||
448 | return (XID) -1; | |||
449 | } | |||
450 | ||||
451 | int | 426 | int | |
452 | XdmFromID (XID id, unsigned short *data_lenp, char **datap) | 427 | XdmFromID (XID id, unsigned short *data_lenp, char **datap) | |
453 | { | 428 | { | |
454 | XdmAuthorizationPtr auth; | 429 | XdmAuthorizationPtr auth; | |
455 | 430 | |||
456 | for (auth = xdmAuth; auth; auth=auth->next) { | 431 | for (auth = xdmAuth; auth; auth=auth->next) { | |
457 | if (id == auth->id) { | 432 | if (id == auth->id) { | |
458 | *data_lenp = 16; | 433 | *data_lenp = 16; | |
459 | *datap = (char *) &auth->rho; | 434 | *datap = (char *) &auth->rho; | |
460 | return 1; | 435 | return 1; | |
461 | } | 436 | } | |
462 | } | 437 | } | |
463 | return 0; | 438 | return 0; |