summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Karl Ramm <kcr@mit.edu>2009-03-02 07:29:54 +0000
committerGravatar Karl Ramm <kcr@mit.edu>2009-03-02 07:29:54 +0000
commitacc0a0992fa27f2e0cf893577eba6c3db4afd5df (patch)
treeaf0c565008ac0d60238ae189d3d9f7f8075d4534
parent2e7ac9926a7acb502c3887a4a01f9b17ff1f857d (diff)
19 fields zephyrgrams
-rwxr-xr-xdebian/rules10
-rw-r--r--h/zephyr/zephyr.h11
-rw-r--r--lib/ZParseNot.c41
-rw-r--r--lib/Zinternal.c51
-rw-r--r--server/dispatch.c3
-rw-r--r--server/realm.c3
6 files changed, 107 insertions, 12 deletions
diff --git a/debian/rules b/debian/rules
index 7d7bd51..c06f918 100755
--- a/debian/rules
+++ b/debian/rules
@@ -50,13 +50,13 @@ configure-stamp:
dh_testdir
# Add here commands to configure the package.
-mkdir krb5
- cd krb5 && CFLAGS="-g -Wall" ../configure --with-krb5=/usr --with-openssl=/usr $(CONFIGURE_ROOT)
+ cd krb5 && CFLAGS="" ../configure --with-krb5=/usr --with-openssl=/usr $(CONFIGURE_ROOT)
-mkdir krb45
- cd krb45 && CFLAGS="-g -Wall" ../configure --with-krb4=/usr --with-krb5=/usr $(CONFIGURE_ROOT)
+ cd krb45 && CFLAGS="" ../configure --with-krb4=/usr --with-krb5=/usr $(CONFIGURE_ROOT)
-mkdir krb4
- cd krb4 && CFLAGS="-g -Wall" ../configure --with-krb4=/usr $(CONFIGURE_ROOT)
+ cd krb4 && CFLAGS="" ../configure --with-krb4=/usr $(CONFIGURE_ROOT)
-mkdir no-krb
- cd no-krb && CFLAGS="-g -Wall" ../configure $(CONFIGURE_ROOT)
+ cd no-krb && CFLAGS="" ../configure $(CONFIGURE_ROOT)
touch configure-stamp
build: configure-stamp build-stamp
@@ -66,7 +66,7 @@ build-stamp:
# Add here commands to compile the package.
set -e; \
for dir in krb5 krb45 krb4 ; do \
- $(MAKE) -C $$dir/lib; make -C $$dir/server; \
+ $(MAKE) -C $$dir/lib; $(MAKE) -C $$dir/server; \
done
$(MAKE) -C no-krb
diff --git a/h/zephyr/zephyr.h b/h/zephyr/zephyr.h
index cb3bf46..9dab437 100644
--- a/h/zephyr/zephyr.h
+++ b/h/zephyr/zephyr.h
@@ -40,7 +40,7 @@
#define Z_MAXPKTLEN 1024
#define Z_MAXHEADERLEN 800
#define Z_MAXOTHERFIELDS 10 /* Max unknown fields in ZNotice_t */
-#define Z_NUMFIELDS 17
+#define Z_NUMFIELDS 19
/* Authentication levels returned by ZCheckAuthentication */
#define ZAUTH_FAILED (-1)
@@ -50,6 +50,11 @@
#define ZNOTICE_SOCKADDR 1
#define ZNOTICE_CHARSET 1
+#define ZCHARSET_UNKNOWN 0
+/* The following are from http://www.iana.org/assignments/character-sets */
+#define ZCHARSET_ISO_8859_1 4
+#define ZCHARSET_UTF_8 106
+
typedef char ZPacket_t[Z_MAXPKTLEN];
/* Packet type */
@@ -86,12 +91,12 @@ typedef struct _ZNotice_t {
/* heavily deprecated: */
#define z_sender_addr z_sender_sockaddr.ip4.sin_addr
/* probably a bad idea?: */
-#define z_port z_sender_sockaddr.ip4.sin_port
struct _ZTimeval z_time;
+ unsigned short z_port;
+ unsigned short z_charset;
int z_auth;
int z_checked_auth;
int z_authent_len;
- int z_charset;
char *z_ascii_authent;
char *z_class;
char *z_class_inst;
diff --git a/lib/ZParseNot.c b/lib/ZParseNot.c
index 48fc29e..a897fd0 100644
--- a/lib/ZParseNot.c
+++ b/lib/ZParseNot.c
@@ -117,9 +117,6 @@ ZParseNotice(char *buffer,
BAD_PACKET;
notice->z_time.tv_sec = ntohl((u_long) notice->z_uid.tv.tv_sec);
notice->z_time.tv_usec = ntohl((u_long) notice->z_uid.tv.tv_usec);
- memset(&notice->z_sender_sockaddr, 0, sizeof notice->z_sender_sockaddr);
- notice->z_sender_sockaddr.ip4.sin_family = AF_INET;
- notice->z_sender_sockaddr.ip4.sin_addr = notice->z_uid.zuid_addr;
numfields--;
ptr = next_field(ptr, end);
}
@@ -250,6 +247,44 @@ ZParseNotice(char *buffer,
else
notice->z_multiuid = notice->z_uid;
+ if (numfields && ptr < end) {
+ /* we will take it on faith that ipv6 addresses are longer than ipv4
+ addresses */
+ unsigned char addrbuf[sizeof(notice->z_sender_sockaddr.ip6.sin6_addr)];
+ int len;
+
+ /* because we're paranoid about naughtily misformated packets */
+ if (memchr(ptr, '\0', end - ptr))
+ BAD_PACKET;
+
+ if (ZReadZcode((unsigned char *)ptr, addrbuf, sizeof(addrbuf), &len) == ZERR_BADFIELD)
+ BAD_PACKET;
+
+ if (len == sizeof(notice->z_sender_sockaddr.ip6.sin6_addr))
+ memcpy(&notice->z_sender_sockaddr.ip6.sin6_addr, addrbuf, len);
+ else if (len == sizeof(notice->z_sender_sockaddr.ip4.sin_addr))
+ memcpy(&notice->z_sender_sockaddr.ip4.sin_addr, addrbuf, len);
+ else
+ BAD_PACKET;
+
+ numfields--;
+ ptr = next_field(ptr, end);
+ } else {
+ memset(&notice->z_sender_sockaddr, 0, sizeof notice->z_sender_sockaddr);
+ notice->z_sender_sockaddr.ip4.sin_family = AF_INET;
+ notice->z_sender_sockaddr.ip4.sin_addr = notice->z_uid.zuid_addr;
+ }
+
+ if (numfields && ptr < end) {
+ if (ZReadAscii16(ptr, end-ptr, &notice->z_charset) == ZERR_BADFIELD)
+ BAD_PACKET;
+ notice->z_charset = htons(notice->z_charset);
+
+ numfields--;
+ ptr = next_field(ptr, end);
+ } else
+ notice->z_charset = ZCHARSET_UNKNOWN;
+
for (i=0;ptr < end && i<Z_MAXOTHERFIELDS && numfields;i++,numfields--) {
notice->z_other_fields[i] = ptr;
ptr = next_field(ptr, end);
diff --git a/lib/Zinternal.c b/lib/Zinternal.c
index 504a9a8..ff01db1 100644
--- a/lib/Zinternal.c
+++ b/lib/Zinternal.c
@@ -683,6 +683,11 @@ Z_FormatHeader(ZNotice_t *notice,
(void) memcpy(&notice->z_uid.zuid_addr, &__My_addr, sizeof(__My_addr));
+ (void) memset(&notice->z_sender_sockaddr, 0, sizeof(notice->z_sender_sockaddr));
+ notice->z_sender_sockaddr.ip4.sin_family = AF_INET; /*XXX*/
+ notice->z_sender_sockaddr.ip4.sin_port = notice->z_port;
+ (void) memcpy(&notice->z_sender_sockaddr.ip4.sin_addr, &__My_addr, sizeof(__My_addr));
+
notice->z_multiuid = notice->z_uid;
if (!version[0])
@@ -820,6 +825,12 @@ Z_ZcodeFormatRawHeader(ZNotice_t *notice,
char newrecip[BUFSIZ];
char *ptr, *end;
int i;
+ int addrlen = 0;
+ unsigned char *addraddr = NULL;
+
+ if (!(notice->z_sender_sockaddr.sa.sa_family == AF_INET ||
+ notice->z_sender_sockaddr.sa.sa_family == AF_INET6))
+ return ZERR_ILLVAL;
if (!notice->z_class)
notice->z_class = "";
@@ -929,6 +940,22 @@ Z_ZcodeFormatRawHeader(ZNotice_t *notice,
return (ZERR_HEADERLEN);
ptr += strlen(ptr)+1;
+ if (notice->z_sender_sockaddr.sa.sa_family == AF_INET) {
+ addrlen = sizeof(notice->z_sender_sockaddr.ip4.sin_addr);
+ addraddr = (unsigned char *)&notice->z_sender_sockaddr.ip4.sin_addr;
+ } else if (notice->z_sender_sockaddr.sa.sa_family == AF_INET6) {
+ addrlen = sizeof(notice->z_sender_sockaddr.ip6.sin6_addr);
+ addraddr = (unsigned char *)&notice->z_sender_sockaddr.ip6.sin6_addr;
+ }
+
+ if (ZMakeZcode(ptr, end-ptr, addraddr, addrlen) == ZERR_FIELDLEN)
+ return ZERR_HEADERLEN;
+ ptr += strlen(ptr) + 1;
+
+ if (ZMakeAscii16(ptr, end-ptr, ntohs(notice->z_charset)) == ZERR_FIELDLEN)
+ return ZERR_HEADERLEN;
+ ptr += strlen(ptr) + 1;
+
for (i=0;i<notice->z_num_other_fields;i++)
if (Z_AddField(&ptr, notice->z_other_fields[i], end))
return (ZERR_HEADERLEN);
@@ -952,6 +979,12 @@ Z_FormatRawHeader(ZNotice_t *notice,
char newrecip[BUFSIZ];
char *ptr, *end;
int i;
+ int addrlen = 0;
+ unsigned char *addraddr = NULL;
+
+ if (!(notice->z_sender_sockaddr.sa.sa_family == AF_INET ||
+ notice->z_sender_sockaddr.sa.sa_family == AF_INET6))
+ return ZERR_ILLVAL;
if (!notice->z_class)
notice->z_class = "";
@@ -992,7 +1025,7 @@ Z_FormatRawHeader(ZNotice_t *notice,
ptr += strlen(ptr)+1;
if (ZMakeAscii16(ptr, end-ptr, ntohs(notice->z_port)) == ZERR_FIELDLEN)
- return (ZERR_HEADERLEN);
+ return (ZERR_HEADERLEN);
ptr += strlen(ptr)+1;
if (ZMakeAscii32(ptr, end-ptr, notice->z_auth) == ZERR_FIELDLEN)
@@ -1044,6 +1077,22 @@ Z_FormatRawHeader(ZNotice_t *notice,
sizeof(ZUnique_Id_t)) == ZERR_FIELDLEN)
return (ZERR_HEADERLEN);
ptr += strlen(ptr)+1;
+
+ if (notice->z_sender_sockaddr.sa.sa_family == AF_INET) {
+ addrlen = sizeof(notice->z_sender_sockaddr.ip4.sin_addr);
+ addraddr = (unsigned char *)&notice->z_sender_sockaddr.ip4.sin_addr;
+ } else if (notice->z_sender_sockaddr.sa.sa_family == AF_INET6) {
+ addrlen = sizeof(notice->z_sender_sockaddr.ip6.sin6_addr);
+ addraddr = (unsigned char *)&notice->z_sender_sockaddr.ip6.sin6_addr;
+ }
+
+ if (ZMakeZcode(ptr, end-ptr, addraddr, addrlen) == ZERR_FIELDLEN)
+ return ZERR_HEADERLEN;
+ ptr += strlen(ptr) + 1;
+
+ if (ZMakeAscii16(ptr, end-ptr, ntohs(notice->z_charset)) == ZERR_FIELDLEN)
+ return ZERR_HEADERLEN;
+ ptr += strlen(ptr) + 1;
for (i=0;i<notice->z_num_other_fields;i++)
if (Z_AddField(&ptr, notice->z_other_fields[i], end))
diff --git a/server/dispatch.c b/server/dispatch.c
index bb7fee9..b8ee700 100644
--- a/server/dispatch.c
+++ b/server/dispatch.c
@@ -662,6 +662,9 @@ xmit(ZNotice_t *notice,
partnotice.z_uid.tv.tv_usec);
(void) memcpy((char *)&partnotice.z_uid.zuid_addr, &__My_addr,
sizeof(__My_addr));
+ partnotice.z_sender_sockaddr.ip4.sin_family = AF_INET; /* XXX */
+ (void) memcpy((char *)&partnotice.z_sender_sockaddr.ip4.sin_addr,
+ &__My_addr, sizeof(__My_addr));
}
partnotice.z_message = notice->z_message+offset;
message_len = min(notice->z_message_len-offset, fragsize);
diff --git a/server/realm.c b/server/realm.c
index 297c1f4..6118265 100644
--- a/server/realm.c
+++ b/server/realm.c
@@ -1148,6 +1148,9 @@ realm_sendit_auth(ZNotice_t *notice,
htonl((u_long) partnotice.z_uid.tv.tv_usec);
(void) memcpy((char *)&partnotice.z_uid.zuid_addr, &__My_addr,
sizeof(__My_addr));
+ partnotice.z_sender_sockaddr.ip4.sin_family = AF_INET; /* XXX */
+ (void) memcpy((char *)&partnotice.z_sender_sockaddr.ip4.sin_addr,
+ &__My_addr, sizeof(__My_addr));
}
message_len = min(notice->z_message_len-offset, fragsize);
partnotice.z_message = notice->z_message+offset;