diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-07-07 14:59:30 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-07-07 14:59:30 +0200 |
commit | 95cc814dbd37a4cb5a69b5eac80bd3e5173fe908 (patch) | |
tree | e5adfbc603dd9b70371a77c5f1a5c19ba937f4ae /networking/udhcp/serverpacket.c | |
parent | a51543a3a486ca60018394dda2623fdf1f16a965 (diff) | |
download | busybox-w32-95cc814dbd37a4cb5a69b5eac80bd3e5173fe908.tar.gz busybox-w32-95cc814dbd37a4cb5a69b5eac80bd3e5173fe908.tar.bz2 busybox-w32-95cc814dbd37a4cb5a69b5eac80bd3e5173fe908.zip |
udhcpd: fix a bug in add_lease where it was reading at [-1]
It is not correct when we read lease file!
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to '')
-rw-r--r-- | networking/udhcp/serverpacket.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/networking/udhcp/serverpacket.c b/networking/udhcp/serverpacket.c index c3724e0e2..b48e4159a 100644 --- a/networking/udhcp/serverpacket.c +++ b/networking/udhcp/serverpacket.c | |||
@@ -130,7 +130,8 @@ int FAST_FUNC send_offer(struct dhcp_packet *oldpacket) | |||
130 | uint32_t req_nip; | 130 | uint32_t req_nip; |
131 | uint32_t lease_time_sec = server_config.max_lease_sec; | 131 | uint32_t lease_time_sec = server_config.max_lease_sec; |
132 | uint32_t static_lease_ip; | 132 | uint32_t static_lease_ip; |
133 | uint8_t *req_ip_opt, *p_host_name; | 133 | uint8_t *req_ip_opt; |
134 | const char *p_host_name; | ||
134 | struct option_set *curr; | 135 | struct option_set *curr; |
135 | struct in_addr addr; | 136 | struct in_addr addr; |
136 | 137 | ||
@@ -173,8 +174,13 @@ int FAST_FUNC send_offer(struct dhcp_packet *oldpacket) | |||
173 | bb_error_msg("no IP addresses to give - OFFER abandoned"); | 174 | bb_error_msg("no IP addresses to give - OFFER abandoned"); |
174 | return -1; | 175 | return -1; |
175 | } | 176 | } |
176 | p_host_name = get_option(oldpacket, DHCP_HOST_NAME); | 177 | p_host_name = (const char*) get_option(oldpacket, DHCP_HOST_NAME); |
177 | if (!add_lease(packet.chaddr, packet.yiaddr, server_config.offer_time, p_host_name)) { | 178 | if (add_lease(packet.chaddr, packet.yiaddr, |
179 | server_config.offer_time, | ||
180 | p_host_name, | ||
181 | p_host_name ? (unsigned char)p_host_name[OPT_LEN - OPT_DATA] : 0 | ||
182 | ) == 0 | ||
183 | ) { | ||
178 | bb_error_msg("lease pool is full - OFFER abandoned"); | 184 | bb_error_msg("lease pool is full - OFFER abandoned"); |
179 | return -1; | 185 | return -1; |
180 | } | 186 | } |
@@ -218,7 +224,7 @@ int FAST_FUNC send_ACK(struct dhcp_packet *oldpacket, uint32_t yiaddr) | |||
218 | struct option_set *curr; | 224 | struct option_set *curr; |
219 | uint32_t lease_time_sec; | 225 | uint32_t lease_time_sec; |
220 | struct in_addr addr; | 226 | struct in_addr addr; |
221 | uint8_t *p_host_name; | 227 | const char *p_host_name; |
222 | 228 | ||
223 | init_packet(&packet, oldpacket, DHCPACK); | 229 | init_packet(&packet, oldpacket, DHCPACK); |
224 | packet.yiaddr = yiaddr; | 230 | packet.yiaddr = yiaddr; |
@@ -242,8 +248,12 @@ int FAST_FUNC send_ACK(struct dhcp_packet *oldpacket, uint32_t yiaddr) | |||
242 | if (send_packet(&packet, 0) < 0) | 248 | if (send_packet(&packet, 0) < 0) |
243 | return -1; | 249 | return -1; |
244 | 250 | ||
245 | p_host_name = get_option(oldpacket, DHCP_HOST_NAME); | 251 | p_host_name = (const char*) get_option(oldpacket, DHCP_HOST_NAME); |
246 | add_lease(packet.chaddr, packet.yiaddr, lease_time_sec, p_host_name); | 252 | add_lease(packet.chaddr, packet.yiaddr, |
253 | lease_time_sec, | ||
254 | p_host_name, | ||
255 | p_host_name ? (unsigned char)p_host_name[OPT_LEN - OPT_DATA] : 0 | ||
256 | ); | ||
247 | if (ENABLE_FEATURE_UDHCPD_WRITE_LEASES_EARLY) { | 257 | if (ENABLE_FEATURE_UDHCPD_WRITE_LEASES_EARLY) { |
248 | /* rewrite the file with leases at every new acceptance */ | 258 | /* rewrite the file with leases at every new acceptance */ |
249 | write_leases(); | 259 | write_leases(); |