Discussion:
[Dnsmasq-discuss] [PATCH] cname no longer accepts trailing dot
Petr Menšík
2018-02-26 18:59:53 UTC
Permalink
Hi Simon,

I got reported bug in Fedora [1], that cname is broken in new releases.
At first I though this was false report, but there is still new
regression in cname handling.

Before, it accepted alias with trailing dot. Not it would accept only
target, but not alias.

cname=alias.,target

is no longer valid. The issue is it will count size to skip after
canonicalize. If that ignores trailing dot, next name would be "". And
that is invalid and refused, dnsmasq refuses to start.

I also think that any whitespace like tab should be possible after
comma. So this fixes also 30858e3b9b12500825a5dc4cd67902c3201c1b25.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1498667
--
Petr Men¹ík
Software Engineer
Red Hat, http://www.redhat.com/
email: ***@redhat.com PGP: 65C6C973
Pali Rohár
2018-02-26 19:37:15 UTC
Permalink
- for (arg += strlen(arg)+1; *arg == ' '; arg++);
+ for (arg += arglen+1; *arg && isspace(*arg); arg++);
Hi!

Just one note about this change. Function isspace() is implemented
according to current locale and basically every locale can have
different set of characters marked as "space". E.g. in C locale
isspace() function is truth not only for ASCII space (0x20), but also
e.g. for ASCII tab (0x09). Some people improperly use function isspace()
just because they think it matches only ASCII spaces (0x20).

Due to dependent on locale I would suggest to use explicit set of
characters... but that is just suggestion.
--
Pali Rohár
***@gmail.com
Petr Menšík
2018-02-27 11:05:15 UTC
Permalink
Sure, I know it will accept any whitespace characted, not just spaces.
But no whitespace character is allowed to be in a DNS name. Let alone
begin with it. These spaces can be in configuration file, where TAB is
not unusual thing. I want any of them to be ignored. If they are not,
dnsmasq will refuse to start, telling you CNAME is invalid. No, just
wrong space is there. I think it is ok in this case to allow any space
that current locale knows about. It would not allow special unicode
spaces anyway, because they will not fit into single char.
Post by Pali Rohár
- for (arg += strlen(arg)+1; *arg == ' '; arg++);
+ for (arg += arglen+1; *arg && isspace(*arg); arg++);
Hi!
Just one note about this change. Function isspace() is implemented
according to current locale and basically every locale can have
different set of characters marked as "space". E.g. in C locale
isspace() function is truth not only for ASCII space (0x20), but also
e.g. for ASCII tab (0x09). Some people improperly use function isspace()
just because they think it matches only ASCII spaces (0x20).
Due to dependent on locale I would suggest to use explicit set of
characters... but that is just suggestion.
--
Petr Menšík
Software Engineer
Red Hat, http://www.redhat.com/
email: ***@redhat.com PGP: 65C6C973
Loading...