Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Hosts plugin allows setting invalid hostnames #2185
Steps to Reproduce the Problem
not sure if there are any length limits for hostnames in
entry is written to hosts file
Further Log Files and Output
Thank you for reporting the bug! Unfortunately we do not have a plugin checking for valid (base) names at the moment.
What about adding check/validation/match = BASENAME support in the validation plugin. Then we could specify a regex in src/plugins/hosts/contract.h which checks for valid hostnames (and aliases).
Do you know which hostnames and aliases are allowed?
This would also fix the problem with newlines in hostnames + aliases, see #1719 (but not the problem of newlines in comments...)
i couldn't find any specification for /etc/hosts.
the grammar doesn't have that limitation though.
according to RFC1034 a FQDN is 254 characters max (including root). and a hostname is 63 characters max (which seems to be the more common than the 24 character limit)
what all have in common is that they can't end in a hypen, should start with either an alphanumeric character of a numeric character (depending on which documentation you read) and end with an alphanumeric character.
i'd go with the FQDN definition, and imho a simple check if the basename qualifies at a valid FQDN should be done in the
what do you think ?
musl does the bare minimum
not sure what glibc does, too just too much to read, did a few greps, but couldn't find any validation of the hostname in
i'd go with musl's check but add maybe
@tom-wa actually we already have a kind-of "strict" option: the --with-recommends option. So everything directly implemented in hosts is "non-strict", what you implement as regex in the contract (which is only applied when --with-recommends is used) is "strict".