diff options
author | Dr. Tilmann Bubeck <t.bubeck@reinform.de> | 2013-10-06 15:10:05 +0200 |
---|---|---|
committer | Dr. Tilmann Bubeck <t.bubeck@reinform.de> | 2013-10-06 15:10:05 +0200 |
commit | 92de3583c7aaaa2040728808add2186348859b98 (patch) | |
tree | 9b711468d6bb48c771d3ad0f6ec153845eea8b58 | |
parent | 1555fff4ab458d7d4053f1ea6b74c3e14a65ad63 (diff) | |
download | xorg-app-xauth-92de3583c7aaaa2040728808add2186348859b98.tar.gz |
Rework match_auth_dpy() to be easier to read and maintain (hopefully).
-rw-r--r-- | process.c | 32 |
1 files changed, 24 insertions, 8 deletions
@@ -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; } |