diff options
-rw-r--r-- | networking/udhcp/ChangeLog | 7 | ||||
-rw-r--r-- | networking/udhcp/dhcpd.c | 11 | ||||
-rw-r--r-- | networking/udhcp/options.c | 4 |
3 files changed, 19 insertions, 3 deletions
diff --git a/networking/udhcp/ChangeLog b/networking/udhcp/ChangeLog index 34cfe16f9..13818953b 100644 --- a/networking/udhcp/ChangeLog +++ b/networking/udhcp/ChangeLog | |||
@@ -1,3 +1,10 @@ | |||
1 | 0.9.9 (pending) | ||
2 | + Added sanity check for max_leases (udhcp bug #1285) (me) | ||
3 | + Finally got rid of the trailing space in enviromental vars (me) | ||
4 | + added an new enviromental variable: $mask. It contains the number | ||
5 | of subnet bits for tools like ip route that require it. | ||
6 | (Bastian Blank <waldi@debian.org>, me) | ||
7 | |||
1 | 0.9.8 (021031) | 8 | 0.9.8 (021031) |
2 | + split up README files (me) | 9 | + split up README files (me) |
3 | + use /dev/urandom to seed xid's (instead of time(0)) (me) | 10 | + use /dev/urandom to seed xid's (instead of time(0)) (me) |
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c index 6c16dfeb0..56ddaa942 100644 --- a/networking/udhcp/dhcpd.c +++ b/networking/udhcp/dhcpd.c | |||
@@ -95,6 +95,7 @@ int main(int argc, char *argv[]) | |||
95 | int pid_fd; | 95 | int pid_fd; |
96 | int max_sock; | 96 | int max_sock; |
97 | int sig; | 97 | int sig; |
98 | unsigned long num_ips; | ||
98 | 99 | ||
99 | OPEN_LOG("udhcpd"); | 100 | OPEN_LOG("udhcpd"); |
100 | LOG(LOG_INFO, "udhcp server (v%s) started", VERSION); | 101 | LOG(LOG_INFO, "udhcp server (v%s) started", VERSION); |
@@ -114,7 +115,15 @@ int main(int argc, char *argv[]) | |||
114 | } | 115 | } |
115 | else server_config.lease = LEASE_TIME; | 116 | else server_config.lease = LEASE_TIME; |
116 | 117 | ||
117 | leases = malloc(sizeof(struct dhcpOfferedAddr) * server_config.max_leases); | 118 | /* Sanity check */ |
119 | num_ips = ntohl(server_config.end) - ntohl(server_config.start); | ||
120 | if (server_config.max_leases > num_ips) { | ||
121 | LOG(LOG_ERR, "max_leases value (%lu) not sane, setting to %lu instead", | ||
122 | server_config.max_leases, num_ips); | ||
123 | server_config.max_leases = num_ips; | ||
124 | } | ||
125 | |||
126 | leases = xmalloc(sizeof(struct dhcpOfferedAddr) * server_config.max_leases); | ||
118 | memset(leases, 0, sizeof(struct dhcpOfferedAddr) * server_config.max_leases); | 127 | memset(leases, 0, sizeof(struct dhcpOfferedAddr) * server_config.max_leases); |
119 | read_leases(server_config.lease_file); | 128 | read_leases(server_config.lease_file); |
120 | 129 | ||
diff --git a/networking/udhcp/options.c b/networking/udhcp/options.c index 58144728e..9f95c1558 100644 --- a/networking/udhcp/options.c +++ b/networking/udhcp/options.c | |||
@@ -214,8 +214,8 @@ void attach_option(struct option_set **opt_list, struct dhcp_option *option, cha | |||
214 | DEBUG(LOG_INFO, "Attaching option %s to list", option->name); | 214 | DEBUG(LOG_INFO, "Attaching option %s to list", option->name); |
215 | 215 | ||
216 | /* make a new option */ | 216 | /* make a new option */ |
217 | new = malloc(sizeof(struct option_set)); | 217 | new = xmalloc(sizeof(struct option_set)); |
218 | new->data = malloc(length + 2); | 218 | new->data = xmalloc(length + 2); |
219 | new->data[OPT_CODE] = option->code; | 219 | new->data[OPT_CODE] = option->code; |
220 | new->data[OPT_LEN] = length; | 220 | new->data[OPT_LEN] = length; |
221 | memcpy(new->data + 2, buffer, length); | 221 | memcpy(new->data + 2, buffer, length); |