From cf8bf8391cffc4cd35e634a8b9a3adf954260b88 Mon Sep 17 00:00:00 2001 From: Karl Ramm Date: Mon, 23 Mar 2009 13:50:35 +0000 Subject: Brain dumps used to stash the address of the client for which metadata was being sent in an extra header field. This worked about as well as you might expect. Fortunately we happened to be putting an address in header field 18 anyway, so backwards compatibility should be relatively painless. I don't know which approach is a more egregious hack, but this change at least nets us four less lines of code, which is obviously good, right? Oh, and while we're at it, if the sa_family isn't set on the sender address, just cringe and set it to AF_INET. --- lib/ZParseNot.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/ZParseNot.c') diff --git a/lib/ZParseNot.c b/lib/ZParseNot.c index f5b90cd..97c5225 100644 --- a/lib/ZParseNot.c +++ b/lib/ZParseNot.c @@ -257,8 +257,16 @@ ZParseNotice(char *buffer, if (memchr(ptr, '\0', end - ptr) == NULL) BAD_PACKET; - if (ZReadZcode((unsigned char *)ptr, addrbuf, sizeof(addrbuf), &len) == ZERR_BADFIELD) - BAD_PACKET; + if (*ptr == 'Z') { + if (ZReadZcode((unsigned char *)ptr, addrbuf, + sizeof(addrbuf), &len) == ZERR_BADFIELD) + BAD_PACKET; + } else { + len = sizeof(notice->z_sender_sockaddr.ip4.sin_addr); + if (ZReadAscii(ptr, end - ptr, (unsigned char *)addrbuf, + len) == ZERR_BADFIELD) + BAD_PACKET; + } if (len == sizeof(notice->z_sender_sockaddr.ip6.sin6_addr)) { notice->z_sender_sockaddr.ip6.sin6_family = AF_INET6; @@ -272,7 +280,8 @@ ZParseNotice(char *buffer, numfields--; ptr = next_field(ptr, end); } else { - memset(¬ice->z_sender_sockaddr, 0, sizeof notice->z_sender_sockaddr); + memset(¬ice->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; } -- cgit v1.2.3