-/* $OpenBSD: dhcp.c,v 1.41 2014/11/11 19:59:47 krw Exp $ */
+/* $OpenBSD: dhcp.c,v 1.42 2015/04/15 12:40:57 krw Exp $ */
/*
* Copyright (c) 1995, 1996, 1997, 1998, 1999
void
dhcprelease(struct packet *packet)
{
+ char ciaddrbuf[INET_ADDRSTRLEN];
struct lease *lease;
struct iaddr cip;
int i;
lease = find_lease_by_ip_addr(cip);
}
+ /* Can't do >1 inet_ntoa() in a printf()! */
+ strlcpy(ciaddrbuf, inet_ntoa(packet->raw->ciaddr), sizeof(ciaddrbuf));
+
note("DHCPRELEASE of %s from %s via %s (%sfound)",
- inet_ntoa(packet->raw->ciaddr),
+ ciaddrbuf,
print_hw_addr(packet->raw->htype, packet->raw->hlen,
packet->raw->chaddr),
packet->raw->giaddr.s_addr ? inet_ntoa(packet->raw->giaddr) :
*/
if (!lease->releasing) {
note("DHCPRELEASE of %s from %s via %s (found)",
- inet_ntoa(packet->raw->ciaddr),
+ ciaddrbuf,
print_hw_addr(packet->raw->htype,
packet->raw->hlen, packet->raw->chaddr),
packet->raw->giaddr.s_addr ?
} else {
note("DHCPRELEASE of %s from %s via %s ignored "
"(release already pending)",
- inet_ntoa(packet->raw->ciaddr),
+ ciaddrbuf,
print_hw_addr(packet->raw->htype,
packet->raw->hlen, packet->raw->chaddr),
packet->raw->giaddr.s_addr ?
}
} else {
note("DHCPRELEASE of %s from %s via %s for nonexistent lease",
- inet_ntoa(packet->raw->ciaddr),
+ ciaddrbuf,
print_hw_addr(packet->raw->htype, packet->raw->hlen,
packet->raw->chaddr),
packet->raw->giaddr.s_addr ?
void
dhcp_reply(struct lease *lease)
{
+ char ciaddrbuf[INET_ADDRSTRLEN];
int bufs = 0, packet_length, i;
struct dhcp_packet raw;
struct sockaddr_in to;
raw.hops = state->hops;
raw.op = BOOTREPLY;
+ /* Can't do >1 inet_ntoa() in a printf()! */
+ strlcpy(ciaddrbuf, inet_ntoa(state->ciaddr), sizeof(ciaddrbuf));
+
/* Say what we're doing... */
if ((state->offer == DHCPACK) && (lease->flags & INFORM_NOLEASE))
note("DHCPACK to %s (%s) via %s",
- inet_ntoa(state->ciaddr),
+ ciaddrbuf,
print_hw_addr(lease->hardware_addr.htype,
lease->hardware_addr.hlen, lease->hardware_addr.haddr),
state->giaddr.s_addr ? inet_ntoa(state->giaddr) :