Skip to content

Commit aab6386

Browse files
wcawijngaardsk0ekk0ek
authored andcommitted
Fix the nsec3param type parse, the uppercase letter mask was too short.
1 parent 21518fe commit aab6386

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/generic/type.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static really_inline int32_t scan_type_or_class(
118118
const char *data, size_t length, uint16_t *code, const mnemonic_t **mnemonic)
119119
{
120120
uint64_t input0, input1;
121-
static const uint64_t letter_mask = 0x40404040404040llu;
121+
static const uint64_t letter_mask = 0x4040404040404040llu;
122122

123123
// safe, input is padded
124124
memcpy(&input0, data, 8);
@@ -161,7 +161,7 @@ static really_inline int32_t scan_type(
161161
const char *data, size_t length, uint16_t *code, const mnemonic_t **mnemonic)
162162
{
163163
uint64_t input0, input1;
164-
static const uint64_t letter_mask = 0x40404040404040llu;
164+
static const uint64_t letter_mask = 0x4040404040404040llu;
165165

166166
// safe, input is padded
167167
memcpy(&input0, data, 8);

tests/types.c

+11
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,16 @@ static const rdata_t nsec_rdata =
489489
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
490490
0x00, 0x00, 0x00, 0x00, 0x20);
491491

492+
static const char nsec_text_2[] =
493+
PAD("alfa.example.com. 86400 IN NSEC host.example.com. ns soa rrsig dnskey nsec3param");
494+
495+
static const rdata_t nsec_rdata_2 =
496+
RDATA(0x04, 'h', 'o', 's', 't',
497+
0x07, 'e', 'x', 'a', 'm', 'p', 'l', 'e',
498+
0x03, 'c', 'o', 'm', 0x00,
499+
0x00, 0x07, 0x22, 0x00, 0x00, 0x00, 0x00, 0x02,
500+
0x90);
501+
492502
// https://datatracker.ietf.org/doc/html/rfc5155#appendix-B.2.1
493503
static const char nsec3_no_data_text[] =
494504
PAD("ji6neoaepv8b5o6k4ev33abha8ht9fgc.example. NSEC3 1 1 12 aabbccdd (\n"
@@ -948,6 +958,7 @@ static const test_t tests[] = {
948958
{ ZONE_TYPE_IPSECKEY, ipseckey_ipv6_text, &ipseckey_ipv6_rdata },
949959
{ ZONE_TYPE_IPSECKEY, ipseckey_name_text, &ipseckey_name_rdata },
950960
{ ZONE_TYPE_NSEC, nsec_text, &nsec_rdata },
961+
{ ZONE_TYPE_NSEC, nsec_text_2, &nsec_rdata_2 },
951962
{ ZONE_TYPE_NSEC3, nsec3_no_data_text, &nsec3_no_data_rdata },
952963
{ ZONE_TYPE_DHCID, dhcid_text, &dhcid_rdata },
953964
{ ZONE_TYPE_DHCID, dhcid_generic_text, &dhcid_rdata },

0 commit comments

Comments
 (0)