diff options
author | Marcus Bointon <marcus@synchromedia.co.uk> | 2017-01-03 23:32:22 +0100 |
---|---|---|
committer | Joe Watkins <krakjoe@php.net> | 2017-01-18 17:23:08 +0000 |
commit | 280e9cb28d07a69e56ebcde4c368f3053298abe3 (patch) | |
tree | a6c1cf43bf9dc01a38c4a606b0186dc3c11d6ab4 /ext/standard/dns.c | |
parent | e7e96fe2e082ec55c1fd069a7e5af207128e91b9 (diff) | |
download | php-git-280e9cb28d07a69e56ebcde4c368f3053298abe3.tar.gz |
DNS CAA record type implementation and tests for https://bugs.php.net/bug.php?id=73850
Diffstat (limited to 'ext/standard/dns.c')
-rw-r--r-- | ext/standard/dns.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/ext/standard/dns.c b/ext/standard/dns.c index f91bffca8c..e0604698bb 100644 --- a/ext/standard/dns.c +++ b/ext/standard/dns.c @@ -114,6 +114,9 @@ #ifndef DNS_T_A6 #define DNS_T_A6 38 #endif +#ifndef DNS_T_CAA +#define DNS_T_CAA 257 +#endif #ifndef DNS_T_ANY #define DNS_T_ANY 255 @@ -286,7 +289,7 @@ static zend_string *php_gethostbyname(char *name) /* }}} */ #if HAVE_FULL_DNS_FUNCS || defined(PHP_WIN32) -# define PHP_DNS_NUM_TYPES 12 /* Number of DNS Types Supported by PHP currently */ +# define PHP_DNS_NUM_TYPES 13 /* Number of DNS Types Supported by PHP currently */ # define PHP_DNS_A 0x00000001 # define PHP_DNS_NS 0x00000002 @@ -294,6 +297,7 @@ static zend_string *php_gethostbyname(char *name) # define PHP_DNS_SOA 0x00000020 # define PHP_DNS_PTR 0x00000800 # define PHP_DNS_HINFO 0x00001000 +# define PHP_DNS_CAA 0x00002000 # define PHP_DNS_MX 0x00004000 # define PHP_DNS_TXT 0x00008000 # define PHP_DNS_A6 0x01000000 @@ -301,7 +305,7 @@ static zend_string *php_gethostbyname(char *name) # define PHP_DNS_NAPTR 0x04000000 # define PHP_DNS_AAAA 0x08000000 # define PHP_DNS_ANY 0x10000000 -# define PHP_DNS_ALL (PHP_DNS_A|PHP_DNS_NS|PHP_DNS_CNAME|PHP_DNS_SOA|PHP_DNS_PTR|PHP_DNS_HINFO|PHP_DNS_MX|PHP_DNS_TXT|PHP_DNS_A6|PHP_DNS_SRV|PHP_DNS_NAPTR|PHP_DNS_AAAA) +# define PHP_DNS_ALL (PHP_DNS_A|PHP_DNS_NS|PHP_DNS_CNAME|PHP_DNS_SOA|PHP_DNS_PTR|PHP_DNS_HINFO|PHP_DNS_CAA|PHP_DNS_MX|PHP_DNS_TXT|PHP_DNS_A6|PHP_DNS_SRV|PHP_DNS_NAPTR|PHP_DNS_AAAA) #endif /* HAVE_FULL_DNS_FUNCS || defined(PHP_WIN32) */ /* Note: These functions are defined in ext/standard/dns_win32.c for Windows! */ @@ -384,6 +388,7 @@ PHP_FUNCTION(dns_check_record) else if (!strcasecmp("PTR", rectype)) type = DNS_T_PTR; else if (!strcasecmp("ANY", rectype)) type = DNS_T_ANY; else if (!strcasecmp("SOA", rectype)) type = DNS_T_SOA; + else if (!strcasecmp("CAA", rectype)) type = DNS_T_CAA; else if (!strcasecmp("TXT", rectype)) type = DNS_T_TXT; else if (!strcasecmp("CNAME", rectype)) type = DNS_T_CNAME; else if (!strcasecmp("AAAA", rectype)) type = DNS_T_AAAA; @@ -529,6 +534,23 @@ static u_char *php_parserr(u_char *cp, u_char *end, querybuf *answer, int type_t add_assoc_stringl(subarray, "os", (char*)cp, n); cp += n; break; + case DNS_T_CAA: + /* See RFC 6844 for values https://tools.ietf.org/html/rfc6844 */ + add_assoc_string(subarray, "type", "CAA"); + // 1 flag byte + CHECKCP(1); + n = *cp & 0xFF; + add_assoc_long(subarray, "flags", n); + cp++; + // Tag length (1 byte) + CHECKCP(1); + n = *cp & 0xFF; + cp++; + CHECKCP(n); + add_assoc_stringl(subarray, "tag", (char*)cp, n); + cp += n; + add_assoc_string(subarray, "value", (char*)cp); + break; case DNS_T_TXT: { int l1 = 0, l2 = 0; @@ -879,6 +901,9 @@ PHP_FUNCTION(dns_get_record) case 11: type_to_fetch = type_param&PHP_DNS_A6 ? DNS_T_A6 : 0; break; + case 12: + type_to_fetch = type_param&PHP_DNS_CAA ? DNS_T_CAA : 0; + break; case PHP_DNS_NUM_TYPES: store_results = 0; continue; @@ -1095,6 +1120,7 @@ PHP_MINIT_FUNCTION(dns) { REGISTER_LONG_CONSTANT("DNS_SOA", PHP_DNS_SOA, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DNS_PTR", PHP_DNS_PTR, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DNS_HINFO", PHP_DNS_HINFO, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("DNS_CAA", PHP_DNS_CAA, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DNS_MX", PHP_DNS_MX, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DNS_TXT", PHP_DNS_TXT, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DNS_SRV", PHP_DNS_SRV, CONST_CS | CONST_PERSISTENT); |