diff mbox series

[LEDE-DEV,v1] dnsmasq: fix dhcp-host entries with empty macs

Message ID 20171128113840.52061-1-ldir@darbyshire-bryant.me.uk
State Accepted
Headers show
Series [LEDE-DEV,v1] dnsmasq: fix dhcp-host entries with empty macs | expand

Commit Message

Kevin 'ldir' Darbyshire-Bryant Nov. 28, 2017, 11:38 a.m. UTC
From: Jo-Philipp Wich <jo@mein.io>

Due to improper localization of helper variables, "config host" entries
without a given mac address may inherit the mac address of a preceeding,
leading to invalid generated netive configuration.

Fix the issue by marking the "macs" and "tags" helper variables in
dhcp_host_add() local, avoiding the need for explicitely resetting them
with each invocation.

Reported-by: Russell Senior <russell@personaltelco.net>
Tested-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
---

jow has this patch lurking in his tree but not yet made it to master,
this is an effort to prompt/remind/encourage before it gets forgotten

 package/network/services/dnsmasq/files/dnsmasq.init | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Jo-Philipp Wich Nov. 28, 2017, 5:11 p.m. UTC | #1
Merged into master with
http://git.lede-project.org/?p=source.git;a=commitdiff;h=fcfd5cdb59.

Thank you!
diff mbox series

Patch

diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init
index 396d3867d4..86291f484d 100644
--- a/package/network/services/dnsmasq/files/dnsmasq.init
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
@@ -253,7 +253,7 @@  dhcp_match_add() {
 
 dhcp_host_add() {
 	local cfg="$1"
-	local hosttag nametime addrs duids
+	local hosttag nametime addrs duids macs tags
 
 	config_get_bool force "$cfg" force 0
 
@@ -281,7 +281,6 @@  dhcp_host_add() {
 	if [ -n "$mac" ]; then
 		# --dhcp-host=00:20:e0:3b:13:af,192.168.0.199,lap
 		# many MAC are possible to track a laptop ON/OFF dock
-		macs=""
 		for m in $mac; do append macs "$m" ","; done
 	fi
 
@@ -302,7 +301,6 @@  dhcp_host_add() {
 		hex_to_hostid hostid "$hostid"
 	fi
 
-	tags=""
 	if [ -n "$tag" ]; then
 		for t in $tag; do append tags "$t" ",set:"; done
 	fi