summaryrefslogtreecommitdiff
path: root/sbin/dhcpleased
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2023-10-10 16:09:54 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2023-10-10 16:09:54 +0000
commitc57e08939758a55003047b7db665b806138127bc (patch)
treef96474ab388f3cd76ddf4a43a9c00e9a5662c4d2 /sbin/dhcpleased
parent5c784d919fb2e8b305cc9d690be5f721074cbe65 (diff)
Do not copy stack garbage, that's not going to be used.
Pointed out by gcc via tb. rdns_count is validated by all callers of propose_rdns(), so we can trust it here to be sensible. While here fix a pasto in an error message. OK tb
Diffstat (limited to 'sbin/dhcpleased')
-rw-r--r--sbin/dhcpleased/dhcpleased.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sbin/dhcpleased/dhcpleased.c b/sbin/dhcpleased/dhcpleased.c
index 1b76a0bd38c..b5f65046894 100644
--- a/sbin/dhcpleased/dhcpleased.c
+++ b/sbin/dhcpleased/dhcpleased.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcpleased.c,v 1.29 2023/02/15 13:47:00 florian Exp $ */
+/* $OpenBSD: dhcpleased.c,v 1.30 2023/10/10 16:09:53 florian Exp $ */
/*
* Copyright (c) 2017, 2021 Florian Obser <florian@openbsd.org>
@@ -601,7 +601,7 @@ main_dispatch_engine(int fd, short event, void *bula)
case IMSG_WITHDRAW_RDNS: {
struct imsg_propose_rdns rdns;
if (IMSG_DATA_SIZE(imsg) != sizeof(rdns))
- fatalx("%s: IMSG_PROPOSE_RDNS wrong "
+ fatalx("%s: IMSG_WITHDRAW_RDNS wrong "
"length: %lu", __func__,
IMSG_DATA_SIZE(imsg));
memcpy(&rdns, imsg.data, sizeof(rdns));
@@ -1197,7 +1197,7 @@ propose_rdns(struct imsg_propose_rdns *rdns)
memset(&rtdns, 0, sizeof(rtdns));
rtdns.sr_family = AF_INET;
rtdns.sr_len = 2 + rdns->rdns_count * sizeof(struct in_addr);
- memcpy(rtdns.sr_dns, rdns->rdns, sizeof(rtdns.sr_dns));
+ memcpy(rtdns.sr_dns, rdns->rdns, rtdns.sr_len - 2);
iov[iovcnt].iov_base = &rtdns;
iov[iovcnt++].iov_len = sizeof(rtdns);