summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2005-04-18 20:46:03 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2005-04-18 20:46:03 +0000
commitfcd7abc72887818d1c3a3765e9f0a1a29cfe306a (patch)
tree7ff87e6f9443d0386c5819d61e3ba8749ced2587
parent0399a9e86903ecc5f0be5016c83e931735c52231 (diff)
extra paranoia, from a discussion with joerg
-rw-r--r--usr.sbin/ntpd/ntpd.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.sbin/ntpd/ntpd.c b/usr.sbin/ntpd/ntpd.c
index a16defa8210..f8b04c3c17e 100644
--- a/usr.sbin/ntpd/ntpd.c
+++ b/usr.sbin/ntpd/ntpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntpd.c,v 1.34 2005/03/31 17:02:43 henning Exp $ */
+/* $OpenBSD: ntpd.c,v 1.35 2005/04/18 20:46:02 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -282,7 +282,11 @@ dispatch_imsg(struct ntpd_conf *conf)
break;
case IMSG_HOST_DNS:
name = imsg.data;
- if (imsg.hdr.len != strlen(name) + 1 + IMSG_HEADER_SIZE)
+ if (imsg.hdr.len < 1 + IMSG_HEADER_SIZE)
+ fatalx("invalid IMSG_HOST_DNS received");
+ imsg.hdr.len -= 1 + IMSG_HEADER_SIZE;
+ if (name[imsg.hdr.len] != '\0' ||
+ strlen(name) != imsg.hdr.len)
fatalx("invalid IMSG_HOST_DNS received");
if ((cnt = host_dns(name, &hn)) > 0) {
buf = imsg_create(ibuf, IMSG_HOST_DNS,