summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2017-04-17 16:03:15 +0000
committerotto <otto@openbsd.org>2017-04-17 16:03:15 +0000
commit4ffc0b90eb8e248a95746c78e7294b6052d3c0a3 (patch)
tree3fccac7861d0a66b2ff4dc6ee7fbc1e9e29badc3
parentChange build infrastructure to allow building both gcc and clang. This (diff)
downloadwireguard-openbsd-4ffc0b90eb8e248a95746c78e7294b6052d3c0a3.tar.xz
wireguard-openbsd-4ffc0b90eb8e248a95746c78e7294b6052d3c0a3.zip
don't manipulate hdr.len, it's used internally by libutil now; ok florian@
-rw-r--r--usr.sbin/ntpd/ntp_dns.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.sbin/ntpd/ntp_dns.c b/usr.sbin/ntpd/ntp_dns.c
index b9611c48eec..c1943243db8 100644
--- a/usr.sbin/ntpd/ntp_dns.c
+++ b/usr.sbin/ntpd/ntp_dns.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntp_dns.c,v 1.19 2016/09/26 16:55:02 rzalamena Exp $ */
+/* $OpenBSD: ntp_dns.c,v 1.20 2017/04/17 16:03:15 otto Exp $ */
/*
* Copyright (c) 2003-2008 Henning Brauer <henning@openbsd.org>
@@ -134,6 +134,7 @@ dns_dispatch_imsg(void)
struct ntp_addr *h, *hn;
struct ibuf *buf;
const char *str;
+ size_t len;
if (((n = imsg_read(ibuf_dns)) == -1 && errno != EAGAIN) || n == 0)
return (-1);
@@ -155,9 +156,9 @@ dns_dispatch_imsg(void)
name = imsg.data;
if (imsg.hdr.len < 1 + IMSG_HEADER_SIZE)
fatalx("invalid %s received", str);
- imsg.hdr.len -= 1 + IMSG_HEADER_SIZE;
- if (name[imsg.hdr.len] != '\0' ||
- strlen(name) != imsg.hdr.len)
+ len = imsg.hdr.len - 1 - IMSG_HEADER_SIZE;
+ if (name[len] != '\0' ||
+ strlen(name) != len)
fatalx("invalid %s received", str);
if ((cnt = host_dns(name, &hn)) == -1)
break;