예제 #1
0
/*
 * SOA RNAMEs and RP RNAMEs can have any printable character in their first
 * label, but the rest of the name has to look like a host name.
 */
int
res_mailok(
    const char *dn
    )
{
    int ch, escaped = 0;

    /* "." is a valid missing representation */
    if (*dn == '\0')
        return (1);

    /* otherwise <label>.<hostname> */
    while ((ch = *dn++) != '\0') {
        if (!domainchar(ch))
            return (0);
        if (!escaped && periodchar(ch))
            break;
        if (escaped)
            escaped = 0;
        else if (bslashchar(ch))
            escaped = 1;
    }
    if (periodchar(ch))
        return (res_hnok(dn));
    return (0);
}
예제 #2
0
파일: res_comp.c 프로젝트: AubrCool/glibc
/*
 * This function is quite liberal, since RFC 1034's character sets are only
 * recommendations.
 */
int
res_dnok(const char *dn) {
	int ch;

	while ((ch = *dn++) != '\0')
		if (!domainchar(ch))
			return (0);
	return (1);
}
예제 #3
0
isc_boolean_t
dns_name_ismailbox(const dns_name_t *name) {
	unsigned char *ndata, ch;
	unsigned int n;
	isc_boolean_t first;

	REQUIRE(VALID_NAME(name));
	REQUIRE(name->labels > 0);
	REQUIRE(name->attributes & DNS_NAMEATTR_ABSOLUTE);

	/* 
	 * Root label.
	 */
	if (name->length == 1)
		return (ISC_TRUE);

	ndata = name->ndata;
	n = *ndata++;
	INSIST(n <= 63);
	while (n--) {
		ch = *ndata++;
		if (!domainchar(ch))
			return (ISC_FALSE);
	}
	
	if (ndata == name->ndata + name->length)
		return (ISC_FALSE);

	/*
	 * RFC292/RFC1123 hostname.
	 */
	while (ndata < (name->ndata + name->length)) {
		n = *ndata++;
		INSIST(n <= 63);
		first = ISC_TRUE;
		while (n--) {
			ch = *ndata++;
			if (first || n == 0) {
				if (!borderchar(ch))
					return (ISC_FALSE);
			} else {
				if (!middlechar(ch))
					return (ISC_FALSE);
			}
			first = ISC_FALSE;
		}
	}
	return (ISC_TRUE);
}