summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authorDr. Tilmann Bubeck <t.bubeck@reinform.de>2013-10-06 15:10:05 +0200
committerDr. Tilmann Bubeck <t.bubeck@reinform.de>2013-10-06 15:10:05 +0200
commit92de3583c7aaaa2040728808add2186348859b98 (patch)
tree9b711468d6bb48c771d3ad0f6ec153845eea8b58 /process.c
parent1555fff4ab458d7d4053f1ea6b74c3e14a65ad63 (diff)
downloadxorg-app-xauth-92de3583c7aaaa2040728808add2186348859b98.tar.gz
Rework match_auth_dpy() to be easier to read and maintain (hopefully).
Diffstat (limited to 'process.c')
-rw-r--r--process.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/process.c b/process.c
index 750f6d5..7a5d6d6 100644
--- a/process.c
+++ b/process.c
@@ -1066,14 +1066,30 @@ eq_auth(Xauth *a, Xauth *b)
static int
match_auth_dpy(register Xauth *a, register Xauth *b)
{
- if (a->family != FamilyWild && b->family != FamilyWild &&
- (a->family != b->family || a->address_length != b->address_length ||
- memcmp(a->address, b->address, a->address_length) != 0))
- return 0;
- if (a->number_length != 0 && b->number_length != 0 &&
- (a->number_length != b->number_length ||
- memcmp(a->number, b->number, a->number_length) != 0))
- return 0;
+ if (a->family != FamilyWild && b->family != FamilyWild) {
+ /* Both "a" and "b" are not FamilyWild, they are "normal" families. */
+
+ /* Make sure, that both families match: */
+ if (a->family != b->family)
+ return 0;
+
+ /* By looking at 'man Xsecurity' and the code in
+ * GetAuthByAddr() and XauGetBestAuthByAddr() in libXau, we
+ * decided, that the address is only relevant for "normal"
+ * families and therefore should be ignored for
+ * "FamilyWild". */
+ if (a->address_length != b->address_length ||
+ memcmp(a->address, b->address, a->address_length) != 0)
+ return 0;
+ }
+
+ if (a->number_length != 0 && b->number_length != 0) {
+ /* Both "a" and "b" have a number, make sure they match: */
+ if (a->number_length != b->number_length ||
+ memcmp(a->number, b->number, a->number_length) != 0)
+ return 0;
+ }
+
return 1;
}