From 1f49ca59077f337c6327e80833265ac32932b876 Mon Sep 17 00:00:00 2001 From: Karl Ramm Date: Tue, 24 Mar 2009 03:40:55 +0000 Subject: keep track of total # of incoming header fields, and cksum appropriately --- h/zephyr/zephyr.h | 1 + lib/ZCkZAut.c | 13 ++++++++++--- lib/ZParseNot.c | 1 + server/kstuff.c | 19 ++++++++++++++----- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/h/zephyr/zephyr.h b/h/zephyr/zephyr.h index 2c6a543..c2420f7 100644 --- a/h/zephyr/zephyr.h +++ b/h/zephyr/zephyr.h @@ -112,6 +112,7 @@ typedef struct _ZNotice_t { char *z_other_fields[Z_MAXOTHERFIELDS]; caddr_t z_message; int z_message_len; + int z_num_hdr_fields; } ZNotice_t; /* Subscription structure */ diff --git a/lib/ZCkZAut.c b/lib/ZCkZAut.c index 19ec6d1..46e6472 100644 --- a/lib/ZCkZAut.c +++ b/lib/ZCkZAut.c @@ -103,9 +103,16 @@ Code_t ZCheckZcodeAuthentication(ZNotice_t *notice, cksum1_base = notice->z_multinotice; if (notice->z_num_other_fields) x = notice->z_other_fields[notice->z_num_other_fields - 1]; - else - x = cksum1_base + strlen(cksum1_base) + 1; /* multiuid */ - cksum1_len = x + strlen(x) + 1 - cksum1_base; + else { + /* see also server/kstuff.c:ZCheckRealmAuthentication */ + /* XXXXXXXXXXXXXXXXXXXXXXX */ + x = cksum1_base + strlen(cksum1_base) + 1; /* multinotice */ + if (notice->z_num_hdr_fields > 17) + x = x + strlen(x) + 1; /* multiuid */ + if (notice->z_num_hdr_fields > 18) + x = x + strlen(x) + 1; /* sender */ + } + cksum1_len = x + strlen(x) + 1 - cksum1_base; /* charset / extra field */ /* last part is the message body */ cksum2_base = notice->z_message; diff --git a/lib/ZParseNot.c b/lib/ZParseNot.c index 97c5225..d3076c7 100644 --- a/lib/ZParseNot.c +++ b/lib/ZParseNot.c @@ -77,6 +77,7 @@ ZParseNotice(char *buffer, if (ZReadAscii32(ptr, end-ptr, &temp) == ZERR_BADFIELD) BAD_PACKET; numfields = temp; + notice->z_num_hdr_fields = numfields; ptr = next_field(ptr, end); /*XXX 3 */ diff --git a/server/kstuff.c b/server/kstuff.c index 5ae30d4..3a013e1 100644 --- a/server/kstuff.c +++ b/server/kstuff.c @@ -431,15 +431,24 @@ ZCheckRealmAuthentication(ZNotice_t *notice, cksum0_len = x + strlen(x) + 1 - cksum0_base; /* second part is from z_multinotice through other fields: * - z_multinotice - * - z_multiuid + * - z_multiuid + * - z_sender_(sock)addr + * - z_charset * - z_other_fields[] */ cksum1_base = notice->z_multinotice; if (notice->z_num_other_fields) - x = notice->z_other_fields[notice->z_num_other_fields]; - else - x = cksum1_base + strlen(cksum1_base) + 1; /* multiuid */ - cksum1_len = x + strlen(x) + 1 - cksum1_base; + x = notice->z_other_fields[notice->z_num_other_fields - 1]; + else { + /* see also lib/ZCkZaut.c:ZCheckZcodeAuthentication */ + /* XXXXXXXXXXXXXXXXXXXXXXX */ + x = cksum1_base + strlen(cksum1_base) + 1; /* multinotice */ + if (notice->z_num_hdr_fields > 17) + x = x + strlen(x) + 1; /* multiuid */ + if (notice->z_num_hdr_fields > 18) + x = x + strlen(x) + 1; /* sender */ + } + cksum1_len = x + strlen(x) + 1 - cksum1_base; /* charset / extra field */ /* last part is the message body */ cksum2_base = notice->z_message; -- cgit v1.2.3