Off-by-one error in dns_rdatatype_attributes?
On Support #16775, Jinmei writes to let us know:
I happened to notice one very minor "off-by-one" glitch in lib/dns/rdata.c:dns_rdatatype_attributes, which would be fixed by the following patch. That is, I believe including 255 is more logical according to the meta type range specified by IANA: https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4
This doesn't affect the behavior anyway (hence "very minor"), since RDATATYPE_ATTRIBUTE_SW covers the case of type == 255. But the "fixed" code would be less confusing for code readers.
(BTW: If 255 was intentionally excluded because the type is not "UNKNOWN", I'd say 249-254 should also be excluded).
diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c
index c8453aae5c..7a281c2ef7 100644
--- a/lib/dns/rdata.c
+++ b/lib/dns/rdata.c
@@ -1286,7 +1286,7 @@ dns_rdata_checknames(dns_rdata_t *rdata, const dns_name_t *owner,
unsigned int
dns_rdatatype_attributes(dns_rdatatype_t type) {
RDATATYPE_ATTRIBUTE_SW
- if (type >= (dns_rdatatype_t)128 && type < (dns_rdatatype_t)255) {
+ if (type >= (dns_rdatatype_t)128 && type <= (dns_rdatatype_t)255) {
return (DNS_RDATATYPEATTR_UNKNOWN | DNS_RDATATYPEATTR_META);
}
return (DNS_RDATATYPEATTR_UNKNOWN);
Has he discovered an error on our part or was this done intentionally (in which case, can we explain why?)