summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEgbert Eich <eich@suse.de>2004-03-01 15:06:59 +0000
committerEgbert Eich <eich@suse.de>2004-03-01 15:06:59 +0000
commit359cf827deb7dc02abbbdff482f90d5487584905 (patch)
tree9a887948e01136aa11a485ba5a18e1b964c5362a
parent260009f58959021e46ae7926dfc9da12caafd5ee (diff)
3. Added missing parts to XKB to make XEVIE branch compile (Egbert Eich).XEVIE
2. Merged with XORG-CURRENT branch to obtain a bugfix (Egbert Eich). 1. First add of SUN's XIVIE extension (Stuart Kreitman).
-rw-r--r--process.c83
1 files changed, 78 insertions, 5 deletions
diff --git a/process.c b/process.c
index 5d7d2ba..d5cb9c8 100644
--- a/process.c
+++ b/process.c
@@ -26,8 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
-/* $XdotOrg: xc/programs/xauth/process.c,v 3.23 2003/11/25 03:15:04 dawes Exp $ */
-/* $XFree86: xc/programs/xauth/process.c,v 3.23 2003/11/25 03:15:04 dawes Exp $ */
+/* $XFree86: xc/programs/xauth/process.c,v 3.24 2004/01/21 23:49:40 herrb Exp $ */
/*
* Author: Jim Fulton, MIT X Consortium
@@ -1050,6 +1049,20 @@ extract_entry(char *inputfilename, int lineno, Xauth *auth, char *data)
}
+static int
+eq_auth(Xauth *a, Xauth *b)
+{
+ return((a->family == b->family &&
+ a->address_length == b->address_length &&
+ a->number_length == b->number_length &&
+ a->name_length == b->name_length &&
+ a->data_length == b->data_length &&
+ memcmp(a->address, b->address, a->address_length) == 0 &&
+ memcmp(a->number, b->number, a->number_length) == 0 &&
+ memcmp(a->name, b->name, a->name_length) == 0 &&
+ memcmp(a->data, b->data, a->data_length) == 0) ? 1 : 0);
+}
+
static int
match_auth_dpy(register Xauth *a, register Xauth *b)
{
@@ -1135,6 +1148,62 @@ merge_entries(AuthList **firstp, AuthList *second, int *nnewp, int *nreplp)
}
+static Xauth *
+copyAuth(Xauth *auth)
+{
+ Xauth *a;
+
+ a = (Xauth *)malloc(sizeof(Xauth));
+ if (a == NULL) {
+ return NULL;
+ }
+ memset(a, 0, sizeof(Xauth));
+ a->family = auth->family;
+ if (auth->address_length != 0) {
+ a->address = malloc(auth->address_length);
+ if (a->address == NULL) {
+ free(a);
+ return NULL;
+ }
+ memcpy(a->address, auth->address, auth->address_length);
+ a->address_length = auth->address_length;
+ }
+ if (auth->number_length != 0) {
+ a->number = malloc(auth->number_length);
+ if (a->number == NULL) {
+ free(a->address);
+ free(a);
+ return NULL;
+ }
+ memcpy(a->number, auth->number, auth->number_length);
+ a->number_length = auth->number_length;
+ }
+ if (auth->name_length != 0) {
+ a->name = malloc(auth->name_length);
+ if (a->name == NULL) {
+ free(a->address);
+ free(a->number);
+ free(a);
+ return NULL;
+ }
+ memcpy(a->name, auth->name, auth->name_length);
+ a->name_length = auth->name_length;
+ }
+ if (auth->data_length != 0) {
+ a->data = malloc(auth->data_length);
+ if (a->data == NULL) {
+ free(a->address);
+ free(a->number);
+ free(a->name);
+ free(a);
+ return NULL;
+ }
+ memcpy(a->data, auth->data, auth->data_length);
+ a->data_length = auth->data_length;
+ }
+ return a;
+}
+
typedef int (*YesNoFunc)(char *, int, Xauth *, char *);
static int
@@ -1145,6 +1214,7 @@ iterdpy (char *inputfilename, int lineno, int start,
int i;
int status;
int errors = 0;
+ Xauth *tmp_auth;
AuthList *proto_head, *proto;
AuthList *l, *next;
@@ -1163,17 +1233,20 @@ iterdpy (char *inputfilename, int lineno, int start,
for (l = xauth_head; l; l = next) {
Bool matched = False;
+ /* l may be freed by remove_entry below. so save its contents */
next = l->next;
+ tmp_auth = copyAuth(l->auth);
for (proto = proto_head; proto; proto = proto->next) {
- if (match_auth_dpy (proto->auth, l->auth)) {
+ if (match_auth_dpy (proto->auth, tmp_auth)) {
matched = True;
if (yfunc) {
status = (*yfunc) (inputfilename, lineno,
- l->auth, data);
+ tmp_auth, data);
if (status < 0) break;
}
}
}
+ XauDisposeAuth(tmp_auth);
if (matched == False) {
if (nfunc) {
status = (*nfunc) (inputfilename, lineno,
@@ -1209,7 +1282,7 @@ remove_entry(char *inputfilename, int lineno, Xauth *auth, char *data)
/*
* unlink the auth we were asked to
*/
- while ((list = *listp)->auth != auth)
+ while (!eq_auth((list = *listp)->auth, auth))
listp = &list->next;
*listp = list->next;
XauDisposeAuth (list->auth); /* free the auth */