summaryrefslogtreecommitdiff
path: root/lib/Zinternal.c
diff options
context:
space:
mode:
authorGravatar Greg Hudson <ghudson@mit.edu>2000-01-26 22:48:53 +0000
committerGravatar Greg Hudson <ghudson@mit.edu>2000-01-26 22:48:53 +0000
commitce7beebd593f970d40ca45e201a1f0d0a1e2a41a (patch)
tree8a4c6ac82c82fd5615d7df373b3961598e482e55 /lib/Zinternal.c
parentfd290afe3ff9446dd53d8c3cc02a1b1050f13f31 (diff)
Discard packets which don't begin with ZVERSIONHDR ("ZEPH") in case we
get non-Zephyr packets from somewhere. We've seen it happen on Linux with getting rx packets.
Diffstat (limited to 'lib/Zinternal.c')
-rw-r--r--lib/Zinternal.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/lib/Zinternal.c b/lib/Zinternal.c
index 99b7de2..9fb9a3f 100644
--- a/lib/Zinternal.c
+++ b/lib/Zinternal.c
@@ -42,6 +42,7 @@ int __locate_next;
ZSubscription_t *__subscriptions_list;
int __subscriptions_num;
int __subscriptions_next;
+int Z_discarded_packets = 0;
#ifdef HAVE_KRB4
C_Block __Zephyr_session;
@@ -222,10 +223,9 @@ Code_t Z_ReadWait()
ZNotice_t notice;
ZPacket_t packet;
struct sockaddr_in olddest, from;
- int from_len, packet_len, part, partof;
+ int from_len, packet_len, zvlen, part, partof;
char *slash;
Code_t retval;
- register int i;
fd_set fds;
struct timeval tv;
@@ -253,15 +253,12 @@ Code_t Z_ReadWait()
if (!packet_len)
return (ZERR_EOF);
- /* XXX Check for null data (debugging) */
- for (i = packet_len - 1; i >= 0; i--)
- if (packet[i])
- goto not_all_null;
-#ifdef Z_DEBUG
- Z_debug ("got null packet from %s", inet_ntoa (from.sin_addr));
-#endif
- return ZERR_NONE;
- not_all_null:
+ /* Ignore obviously non-Zephyr packets. */
+ zvlen = sizeof(ZVERSIONHDR) - 1;
+ if (packet_len < zvlen || memcmp(packet, ZVERSIONHDR, zvlen) != 0) {
+ Z_discarded_packets++;
+ return (ZERR_NONE);
+ }
/* Parse the notice */
if ((retval = ZParseNotice(packet, packet_len, &notice)) != ZERR_NONE)