From c7961075c426c8afaca65ebe68299c505c7417cd Mon Sep 17 00:00:00 2001 From: Simon Kelley Date: Thu, 28 Feb 2013 15:17:58 +0000 Subject: [PATCH] Don't erroneously reject some option names in --dhcp-match --- CHANGELOG | 3 +++ src/dhcp-common.c | 14 ++++---------- src/option.c | 4 ++++ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 50b17aa..854992b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -46,6 +46,9 @@ version 2.66 Add --ipset option. Thanks to Jason A. Donenfeld for the patch. + Don't erroneously reject some option names in --dhcp-match + options. Thnaks to Benedikt Hochstrasser for the bug report. + version 2.65 Fix regression which broke forwarding of queries sent via diff --git a/src/dhcp-common.c b/src/dhcp-common.c index 8e18c06..3f21267 100644 --- a/src/dhcp-common.c +++ b/src/dhcp-common.c @@ -518,8 +518,7 @@ u16 lookup_dhcp_opt(int prot, char *name) t = opttab; for (i = 0; t[i].name; i++) - if (!(t[i].size & OT_INTERNAL) && - strcasecmp(t[i].name, name) == 0) + if (strcasecmp(t[i].name, name) == 0) return t[i].val; return 0; @@ -539,14 +538,9 @@ u16 lookup_dhcp_len(int prot, u16 val) for (i = 0; t[i].name; i++) if (val == t[i].val) - { - if (t[i].size & OT_INTERNAL) - return 0; - - return t[i].size & ~OT_DEC; - } - - return 0; + return t[i].size & ~OT_DEC; + + return 0; } char *option_string(int prot, unsigned int opt, unsigned char *val, int opt_len, char *buf, int buf_len) diff --git a/src/option.c b/src/option.c index 9315694..74d9a0c 100644 --- a/src/option.c +++ b/src/option.c @@ -768,6 +768,8 @@ static int parse_dhcp_opt(char *errstr, char *arg, int flags) new->opt = lookup_dhcp_opt(AF_INET, arg+7); opt_len = lookup_dhcp_len(AF_INET, new->opt); /* option: must follow tag and vendor string. */ + if ((opt_len & OT_INTERNAL) && flags != DHOPT_MATCH) + new->opt = 0; break; } #ifdef HAVE_DHCP6 @@ -786,6 +788,8 @@ static int parse_dhcp_opt(char *errstr, char *arg, int flags) { new->opt = lookup_dhcp_opt(AF_INET6, arg+8); opt_len = lookup_dhcp_len(AF_INET6, new->opt); + if ((opt_len & OT_INTERNAL) && flags != DHOPT_MATCH) + new->opt = 0; } /* option6:| must follow tag and vendor string. */ is6 = 1;