summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de>2004-03-17 20:32:24 +0000
committerAlexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de>2004-03-17 20:32:24 +0000
commitf4cc7fb58faf117f45370b616029c168d1b0a52c (patch)
treebc5bc9e89e76dd9365abc21e4173c86817b8f485
parentfe29169f363b143eee5d290d5388c460c45d41ba (diff)
-rw-r--r--gethost.c2
-rw-r--r--parsedpy.c2
-rw-r--r--process.c85
-rw-r--r--xauth.c2
-rw-r--r--xauth.h2
-rw-r--r--xauth.man2
6 files changed, 85 insertions, 10 deletions
diff --git a/gethost.c b/gethost.c
index 74f5e1c..fa511c1 100644
--- a/gethost.c
+++ b/gethost.c
@@ -26,7 +26,7 @@ in this Software without prior written authorization from The Open Group.
* Author: Jim Fulton, MIT X Consortium
*/
-/* $XFree86: xc/programs/xauth/gethost.c,v 3.21 2003/08/02 15:30:10 herrb Exp $ */
+/* $XFree86: xc/programs/xauth/gethost.c,v 3.20 2003/07/27 12:34:25 herrb Exp $ */
/* sorry, streams support does not really work yet */
#if defined(STREAMSCONN) && defined(SVR4)
diff --git a/parsedpy.c b/parsedpy.c
index bdd32c3..d7b5a4a 100644
--- a/parsedpy.c
+++ b/parsedpy.c
@@ -29,7 +29,7 @@ in this Software without prior written authorization from The Open Group.
* Author: Jim Fulton, MIT X Consortium
*/
-/* $XFree86: xc/programs/xauth/parsedpy.c,v 3.8 2003/07/18 15:53:28 tsi Exp $ */
+/* $XFree86: xc/programs/xauth/parsedpy.c,v 3.7 2003/07/09 15:27:37 tsi Exp $ */
#include <stdio.h> /* for NULL */
#include <ctype.h> /* for isascii() and isdigit() */
diff --git a/process.c b/process.c
index ee5b41b..3531260 100644
--- a/process.c
+++ b/process.c
@@ -26,7 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
-/* $XFree86: xc/programs/xauth/process.c,v 3.22 2003/07/18 15:53:28 tsi Exp $ */
+/* $XFree86: xc/programs/xauth/process.c,v 3.23 2003/11/25 03:15:04 dawes Exp $ */
/*
* Author: Jim Fulton, MIT X Consortium
@@ -1049,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)
{
@@ -1134,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
@@ -1144,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;
@@ -1162,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,
@@ -1208,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 */
@@ -1520,7 +1594,7 @@ do_add(char *inputfilename, int lineno, int argc, char **argv)
return 1;
}
auth->data_length = len;
- auth->data = copystring(key, len);
+ auth->data = malloc(len);
if (!auth->data) {
prefix(inputfilename, lineno);
fprintf(stderr, "unable to allocate %d bytes for key\n", len);
@@ -1532,6 +1606,7 @@ do_add(char *inputfilename, int lineno, int argc, char **argv)
free(key);
return 1;
}
+ memcpy(auth->data, key, len);
}
free(key);
/*
diff --git a/xauth.c b/xauth.c
index 9da3269..793903c 100644
--- a/xauth.c
+++ b/xauth.c
@@ -28,7 +28,7 @@ in this Software without prior written authorization from The Open Group.
* *
* Author: Jim Fulton, MIT X Consortium
*/
-/* $XFree86: xc/programs/xauth/xauth.c,v 1.6 2003/07/09 15:27:37 tsi Exp $ */
+/* $XFree86: xc/programs/xauth/xauth.c,v 1.5tsi Exp $ */
#include "xauth.h"
diff --git a/xauth.h b/xauth.h
index ec41f39..51c1d22 100644
--- a/xauth.h
+++ b/xauth.h
@@ -26,7 +26,7 @@ in this Software without prior written authorization from The Open Group.
* *
* Author: Jim Fulton, MIT X Consortium
*/
-/* $XFree86: xc/programs/xauth/xauth.h,v 1.7 2003/07/09 15:27:37 tsi Exp $ */
+/* $XFree86: xc/programs/xauth/xauth.h,v 1.6tsi Exp $ */
#include <stdio.h>
#include <X11/Xos.h>
diff --git a/xauth.man b/xauth.man
index 6cdda4c..273db0c 100644
--- a/xauth.man
+++ b/xauth.man
@@ -23,7 +23,7 @@
.\" other dealings in this Software without prior written authorization
.\" from The Open Group.
.\"
-.\" $XFree86: xc/programs/xauth/xauth.man,v 1.9 2003/07/09 15:27:37 tsi Exp $
+.\" $XFree86: xc/programs/xauth/xauth.man,v 1.8tsi Exp $
.\"
.TH XAUTH 1 __xorgversion__
.SH NAME