Source-Changes-D archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: CVS commit: src/lib/libc/net
Erik Fair <fair%netbsd.org@localhost> wrote:
|So, what did we do by default: allow “_” in hostnames when that’s exp\
|licitly against standard, or not? I read the patch in the PR and coul\
|dn’t make heads or tails of it.
fwiw i don't think this is generally true, my own one has
a DNS::verifyName() and that does
// find label border, if any
#if(_ASSUME_LONG)
wbuf = s(char*,Mem::Utils::find(_dname, _DOT, _dnamelen));
llen = (wbuf ? s(ui32,wbuf-_dname) : _dnamelen);
#else
for(wbuf=_dname, llen^=llen; llen < _dnamelen; ++llen)
if(*(wbuf++) == _DOT)
break;
#endif
if(!llen || llen > 63)
goto jesll;
[and]
// 1033, 1034, 2929 (3.3): rather anything (printable ASCII)
[these numbers are RFCs, vnm_ is enum DNS::VerifyNameMode:
vnm_none = 0, // boundary checks only
vnm_boundary = vnm_none,
vnm_dname = 1, // printable ASCII
vnm_hostname = 2, // hostname acc. RFC 1035 + 1123, 2.1
vnm_srv = 3, // vnm_hostname plus _ label start
]
case vnm_dname:
while(llen--) {
ui8 c = s(ui8,*(wbuf++));
if(!_IS_ASCII_PRINTABLE(c))
goto jeill;
}
break;
// hostname acc. 1035:2.3.1, 1123:2.1
[these numbers are RFCs]
case vnm_hostname:
case vnm_srv:
// may start with letter or digit (latter 1123, 2.1)
if(!_IS_ASCII_ALNUM(wbuf[0]))
// t_srv may start with underscore (RFC 2782)
if(_vnm != vnm_srv || wbuf[0] != _UNDERSCORE)
goto jeill;
// may consist of letters, digits and hyphen
while(s(si32,--llen) > 0) {
char c = *(++wbuf);
if(c != _HYPHEN && !_IS_ASCII_ALNUM(c))
goto jeill;
}
// but may end with letter or digit only
if(wbuf[0] == _HYPHEN)
goto jeill;
break;
} // switch(_vnm)
and then
?0[sdaoden@wales ]$ git grep IS_ASCII_PRI master
master:modules/dns/config.h:#define _IS_ASCII_PRINTABLE(CHAR) ((CHAR) > 0x20 && (CHAR) < 0x7F)
So vnm_srv does regulary allow underscore as in
/*!
* \var vnm_srv
* Boundary check (#vnm_none) plus content verification.
* This is exactly like #vnm_hostname,
* but additionally allows a label to start with an underscore ("_").
* RFC 2782 introduced the use of underscores as a leading character for
* service and protocol names to reduce accidental clashes,
* and thus we support them as required.
* Note however that this check is stupid
* in that \e all labels are allowed to start with underscores \ldots
*/
Oh, it seems not to be completely correct, unfortunately. I think
i should stop tracking -d again.
--steffen
Home |
Main Index |
Thread Index |
Old Index