summaryrefslogtreecommitdiff
path: root/networking/udhcp/dhcpd.c
diff options
context:
space:
mode:
authorRuss Dill2002-12-11 21:40:46 +0000
committerRuss Dill2002-12-11 21:40:46 +0000
commit9f4395c54e9e5507f2a59643f62bb42ef2601aab (patch)
treedff384f34afa3444d0eb9478df78185d05c79b75 /networking/udhcp/dhcpd.c
parent920c1e8d6ca1db73366caaaf14abf242f2b851d3 (diff)
downloadbusybox-9f4395c54e9e5507f2a59643f62bb42ef2601aab.zip
busybox-9f4395c54e9e5507f2a59643f62bb42ef2601aab.tar.gz
sorry about all the noise, should be all synced up now
Diffstat (limited to 'networking/udhcp/dhcpd.c')
-rw-r--r--networking/udhcp/dhcpd.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c
index 6c16dfe..56ddaa9 100644
--- a/networking/udhcp/dhcpd.c
+++ b/networking/udhcp/dhcpd.c
@@ -95,6 +95,7 @@ int main(int argc, char *argv[])
int pid_fd;
int max_sock;
int sig;
+ unsigned long num_ips;
OPEN_LOG("udhcpd");
LOG(LOG_INFO, "udhcp server (v%s) started", VERSION);
@@ -114,7 +115,15 @@ int main(int argc, char *argv[])
}
else server_config.lease = LEASE_TIME;
- leases = malloc(sizeof(struct dhcpOfferedAddr) * server_config.max_leases);
+ /* Sanity check */
+ num_ips = ntohl(server_config.end) - ntohl(server_config.start);
+ if (server_config.max_leases > num_ips) {
+ LOG(LOG_ERR, "max_leases value (%lu) not sane, setting to %lu instead",
+ server_config.max_leases, num_ips);
+ server_config.max_leases = num_ips;
+ }
+
+ leases = xmalloc(sizeof(struct dhcpOfferedAddr) * server_config.max_leases);
memset(leases, 0, sizeof(struct dhcpOfferedAddr) * server_config.max_leases);
read_leases(server_config.lease_file);