From e93f724725d6fcab54560cba0972ff56ce3c4619 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 6 Sep 2013 08:10:54 -0600 Subject: DHCPD: Fix calculation of lease address. Bad logic causes repeated assignment of the same IP address. SourceForge bug #21 from Paolo Messina. --- apps/netutils/dhcpd/dhcpd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'apps/netutils') diff --git a/apps/netutils/dhcpd/dhcpd.c b/apps/netutils/dhcpd/dhcpd.c index d9143288d..ce11ee248 100644 --- a/apps/netutils/dhcpd/dhcpd.c +++ b/apps/netutils/dhcpd/dhcpd.c @@ -1,7 +1,7 @@ /**************************************************************************** * netutils/dhcpd/dhcpd.c * - * Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -363,11 +363,11 @@ struct lease_s *dhcpd_setlease(const uint8_t *mac, in_addr_t ipaddr, time_t expi * Name: dhcp_leaseipaddr ****************************************************************************/ -static inline in_addr_t dhcp_leaseipaddr( struct lease_s *lease) +static inline in_addr_t dhcp_leaseipaddr(struct lease_s *lease) { /* Return IP address in host order */ - return (g_state.ds_leases - lease)/sizeof(struct lease_s) + CONFIG_NETUTILS_DHCPD_STARTIP; + return (in_addr_t)(lease - g_state.ds_leases) + CONFIG_NETUTILS_DHCPD_STARTIP; } /**************************************************************************** -- cgit v1.2.3