diff options
| author | Kris Kennaway <kris@FreeBSD.org> | 2001-08-20 06:16:04 +0000 |
|---|---|---|
| committer | Kris Kennaway <kris@FreeBSD.org> | 2001-08-20 06:16:04 +0000 |
| commit | 73c4a23ef248766d7c279db923249d538b2a0c35 (patch) | |
| tree | 8cc51e678f8787bbe3cc84d132d63f873f2285df | |
| parent | 119c74f12e7813fe24763e45f84f67bb2c515d29 (diff) | |
Notes
| -rw-r--r-- | usr.sbin/timed/timed/readmsg.c | 9 | ||||
| -rw-r--r-- | usr.sbin/timed/timedc/cmds.c | 21 |
2 files changed, 23 insertions, 7 deletions
diff --git a/usr.sbin/timed/timed/readmsg.c b/usr.sbin/timed/timed/readmsg.c index cca415e4f10f..3af91f5137cc 100644 --- a/usr.sbin/timed/timed/readmsg.c +++ b/usr.sbin/timed/timed/readmsg.c @@ -212,10 +212,15 @@ again: syslog(LOG_ERR, "recvfrom: %m"); exit(1); } - if (n < (ssize_t)sizeof(struct tsp)) { + /* + * The 4.3BSD protocol spec had a 32-byte tsp_name field, and + * this is still OS-dependent. Demand that the packet is at + * least long enough to hold a 4.3BSD packet. + */ + if (n < (ssize_t)(sizeof(struct tsp) - MAXHOSTNAMELEN + 32)) { syslog(LOG_NOTICE, "short packet (%u/%u bytes) from %s", - n, sizeof(struct tsp), + n, sizeof(struct tsp) - MAXHOSTNAMELEN + 32, inet_ntoa(from.sin_addr)); continue; } diff --git a/usr.sbin/timed/timedc/cmds.c b/usr.sbin/timed/timedc/cmds.c index 21a5a0478cbb..b1c9c7c892a8 100644 --- a/usr.sbin/timed/timedc/cmds.c +++ b/usr.sbin/timed/timedc/cmds.c @@ -332,10 +332,15 @@ msite(argc, argv) warn("recvfrom"); continue; } - if (cc < sizeof(struct tsp)) { + /* + * The 4.3BSD protocol spec had a 32-byte tsp_name field, and + * this is still OS-dependent. Demand that the packet is at + * least long enough to hold a 4.3BSD packet. + */ + if (cc < (sizeof(struct tsp) - MAXHOSTNAMELEN + 32)) { fprintf(stderr, "short packet (%u/%u bytes) from %s\n", - cc, sizeof(struct tsp), + cc, sizeof(struct tsp) - MAXHOSTNAMELEN + 32, inet_ntoa(from.sin_addr)); continue; } @@ -484,9 +489,15 @@ tracing(argc, argv) warn("recvfrom"); return; } - if (cc < sizeof(struct tsp)) { - fprintf(stderr, "short pack (%u/%u bytes) from %s\n", - cc, sizeof(struct tsp), inet_ntoa(from.sin_addr)); + /* + * The 4.3BSD protocol spec had a 32-byte tsp_name field, and + * this is still OS-dependent. Demand that the packet is at + * least long enough to hold a 4.3BSD packet. + */ + if (cc < (sizeof(struct tsp) - MAXHOSTNAMELEN + 32)) { + fprintf(stderr, "short packet (%u/%u bytes) from %s\n", + cc, sizeof(struct tsp) - MAXHOSTNAMELEN + 32, + inet_ntoa(from.sin_addr)); return; } bytehostorder(&msg); |
