[Dnsmasq-discuss] [PATCH] [BUGFIX] server parsing issue with empty domains

Dominik dl6er at dl6er.de
Fri Aug 20 11:27:00 UTC 2021


Dear Simon,

server=//1.2.3.4 can be used to specify a server to be used for
unqualified names. However, if we want to combine this feature with
other domains, the server config option is parsed incorrectly.

A fix is attached.

---

Example 1:
> server=//192.168.2.1
> server=/fritz.box/192.168.2.1

Log:
> Aug 20 13:00:34 dnsmasq[1151247]: using nameserver 192.168.2.1#53 for
> unqualified names (no DNSSEC)
> Aug 20 13:00:34 dnsmasq[1151247]: using nameserver 192.168.2.1#53 for
> domain fritz.box (no DNSSEC)

CORRECT

Example 2:
> server=//fritz.box/192.168.2.1

Log:

> Aug 20 12:33:41 dnsmasq[1147692]: using nameserver 192.168.2.1#53 for
> unqualified names (no DNSSEC)
> Aug 20 12:33:41 dnsmasq[1147692]: using nameserver 192.168.2.1#53 for
> unqualified names (no DNSSEC)

WRONG (not using the server for fritz.box)

Example 3:
> server=/fritz.box//192.168.2.1

Log:
> Aug 20 12:30:27 dnsmasq[1147304]: using nameserver 192.168.2.1#53 for
> domain fritz.box (no DNSSEC)
> Aug 20 12:30:27 dnsmasq[1147304]: using nameserver 192.168.2.1#53

WRONG (uses server for all domains instead of only unqualified)

----

The bug has been introduced about two months ago in
12a9aa7c628e2d7dcd34949603848a3fb53fce9c

The issue is now caused by interpreting the server flags only once. If
// is the first domain, SERV_FOR_NODOTS is set to all domains extracted
from a server config line. If // appears later on, SERV_FOR_NODOTS is
never set, leading to the misinterpretation that server=//192.168.2.1
is the same as server=192.168.2.1.

The attached patch fixes this by adding SERV_FOR_NODOTS *selectively*
for empty domains. It does this only when // is detected.

All three examples work as expected now.

Best,
Dominik
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-empty-domain-in-server-option-parsing-when-more-.patch
Type: text/x-patch
Size: 1284 bytes
Desc: not available
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20210820/c88878f3/attachment.bin>


More information about the Dnsmasq-discuss mailing list