From: otto Date: Mon, 22 Mar 2021 15:34:07 +0000 (+0000) Subject: Avoid overflow by writing x = (y * 7) / 8 as x = y - (y / 8); ok florian X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=07355dbd1c9004d45f7d53fe0bfb68d90547f648;p=openbsd Avoid overflow by writing x = (y * 7) / 8 as x = y - (y / 8); ok florian --- diff --git a/sbin/dhcpleased/engine.c b/sbin/dhcpleased/engine.c index 7fda133d37b..a98dc3d59e7 100644 --- a/sbin/dhcpleased/engine.c +++ b/sbin/dhcpleased/engine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: engine.c,v 1.10 2021/03/16 17:40:28 florian Exp $ */ +/* $OpenBSD: engine.c,v 1.11 2021/03/22 15:34:07 otto Exp $ */ /* * Copyright (c) 2017, 2021 Florian Obser @@ -975,7 +975,7 @@ parse_dhcp(struct dhcpleased_iface *iface, struct imsg_dhcp *dhcp) if(renewal_time == 0) renewal_time = lease_time / 2; if (rebinding_time == 0) - rebinding_time = (lease_time * 7) / 8; + rebinding_time = lease_time - (lease_time / 8); if (renewal_time >= rebinding_time) { log_warnx("%s: renewal_time >= rebinding_time "