diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2017-08-17 12:16:07 +0200 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2017-08-17 12:16:38 +0200 |
commit | 1a313f9052e315571f42e9888d7bc8e443c5bb56 (patch) | |
tree | 1523f85b0cdfb735abaa59b3c3571cbf7c417920 /src/dhcpv4.c | |
parent | e2d6eb4148d5c575cea23617e938982bd5d93abc (diff) |
dhcpv4: fix possible segfault when lease is not created
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'src/dhcpv4.c')
-rw-r--r-- | src/dhcpv4.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/dhcpv4.c b/src/dhcpv4.c index db900c1..c7ac058 100644 --- a/src/dhcpv4.c +++ b/src/dhcpv4.c @@ -587,7 +587,6 @@ static struct dhcpv4_assignment* dhcpv4_lease(struct interface *iface, if (msg == DHCPV4_MSG_DISCOVER || msg == DHCPV4_MSG_REQUEST) { bool assigned = !!a; - uint32_t my_leasetime; if (!a && !iface->no_dynamic_dhcp) { /* Create new binding */ @@ -605,15 +604,17 @@ static struct dhcpv4_assignment* dhcpv4_lease(struct interface *iface, list_add(&a->head, &iface->dhcpv4_assignments); } - if (a->leasetime) - my_leasetime = a->leasetime; - else - my_leasetime = iface->dhcpv4_leasetime; + if (assigned) { + uint32_t my_leasetime; - if ((*leasetime == 0) || (my_leasetime < *leasetime)) - *leasetime = my_leasetime; + if (a->leasetime) + my_leasetime = a->leasetime; + else + my_leasetime = iface->dhcpv4_leasetime; + + if ((*leasetime == 0) || (my_leasetime < *leasetime)) + *leasetime = my_leasetime; - if (assigned) { if (msg == DHCPV4_MSG_DISCOVER) { a->flags &= ~OAF_BOUND; |