diff options
author | 2014-10-29 15:28:51 +0000 | |
---|---|---|
committer | 2014-10-29 15:28:51 +0000 | |
commit | 4e239eaff70e6fa0a811f306a0ddcee906676607 (patch) | |
tree | d8ca571128255b71909e60d70b91b021968b2554 | |
parent | Update test outputs to reflect the fact that routes to loopback addresses (diff) | |
download | wireguard-openbsd-4e239eaff70e6fa0a811f306a0ddcee906676607.tar.xz wireguard-openbsd-4e239eaff70e6fa0a811f306a0ddcee906676607.zip |
Calling a function to htonl() a constant 32-bit value into a stack
variable and memcpy() that value into 4 bytes of malloc()'d space
seems roundabout.
Just memcpy() a four byte constant string into the malloc()'d space
as required and kill putULong(). No functional change.
-rw-r--r-- | sbin/dhclient/convert.c | 10 | ||||
-rw-r--r-- | sbin/dhclient/dhclient.c | 19 | ||||
-rw-r--r-- | sbin/dhclient/dhcpd.h | 3 |
3 files changed, 14 insertions, 18 deletions
diff --git a/sbin/dhclient/convert.c b/sbin/dhclient/convert.c index 544e315ea8b..14ba6f8bb9a 100644 --- a/sbin/dhclient/convert.c +++ b/sbin/dhclient/convert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: convert.c,v 1.8 2014/10/27 17:01:28 krw Exp $ */ +/* $OpenBSD: convert.c,v 1.9 2014/10/29 15:28:51 krw Exp $ */ /* * Safe copying of option values into and out of the option buffer, @@ -53,11 +53,3 @@ getULong(unsigned char *buf) memcpy(&ibuf, buf, sizeof(ibuf)); return (ntohl(ibuf)); } - -void -putULong(unsigned char *obuf, u_int32_t val) -{ - u_int32_t tmp = htonl(val); - - memcpy(obuf, &tmp, sizeof(tmp)); -} diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 95ca12e7bfb..4e1d483eb4b 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.323 2014/10/27 19:54:31 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.324 2014/10/29 15:28:51 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -727,27 +727,32 @@ state_selecting(void) client->new = picked; /* - * Fake up DHO_DHCP_LEASE_TIME, DHO_RENEWAL_TIME and - * DHO_REBINDING_TIME options so bind_lease() can - * set the times. + * Set (unsigned 32 bit) options + * + * DHO_DHCP_LEASE_TIME (12000 seconds), + * DHO_RENEWAL_TIME (8000 seconds) + * DHO_REBINDING_TIME (10000 seconds) + * + * so bind_lease() can set the lease times. Note that the + * values must be big-endian. */ option = &client->new->options[DHO_DHCP_LEASE_TIME]; option->data = malloc(4); if (option->data) { option->len = 4; - putULong(option->data, 12000); + memcpy(option->data, "\x00\x00\x2e\xe0", 4); } option = &client->new->options[DHO_DHCP_RENEWAL_TIME]; option->data = malloc(4); if (option->data) { option->len = 4; - putULong(option->data, 8000); + memcpy(option->data, "\x00\x00\x1f\x40", 4); } option = &client->new->options[DHO_DHCP_REBINDING_TIME]; option->data = malloc(4); if (option->data) { option->len = 4; - putULong(option->data, 10000); + memcpy(option->data, "\x00\x00\x27\x10", 4); } client->state = S_REQUESTING; diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index 77f6fa299a2..28b00d218bc 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.140 2014/10/27 17:01:28 krw Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.141 2014/10/29 15:28:51 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -267,7 +267,6 @@ extern const struct option dhcp_options[256]; /* convert.c */ u_int32_t getULong(unsigned char *); -void putULong(unsigned char *, u_int32_t); /* dhclient.c */ extern char *path_dhclient_conf; |