mirror of
https://github.com/NLnetLabs/unbound.git
synced 2026-02-02 19:59:28 -05:00
- Fix encoding of RR type ATMA.
This commit is contained in:
parent
9a0de14aa1
commit
207ae97ff9
5 changed files with 69 additions and 9 deletions
|
|
@ -6,6 +6,7 @@
|
|||
21 January 2025: Wouter
|
||||
- Fix compile of interface check code when dnscrypt or quic is
|
||||
disabled.
|
||||
- Fix encoding of RR type ATMA.
|
||||
|
||||
20 January 2025: Yorgos
|
||||
- Merge #1222: Unique DoT and DoH SSL contexts to allow for different
|
||||
|
|
|
|||
|
|
@ -2554,12 +2554,40 @@ int sldns_str2wire_atma_buf(const char* str, uint8_t* rd, size_t* len)
|
|||
{
|
||||
const char* s = str;
|
||||
size_t slen = strlen(str);
|
||||
size_t dlen = 0; /* number of hexdigits parsed */
|
||||
size_t dlen = 0; /* number of hexdigits parsed for hex,
|
||||
digits for E.164 */
|
||||
|
||||
/* just a hex string with optional dots? */
|
||||
/* notimpl e.164 format */
|
||||
if(slen > LDNS_MAX_RDFLEN*2)
|
||||
return LDNS_WIREPARSE_ERR_LABEL_OVERFLOW;
|
||||
if(*s == 0) {
|
||||
/* empty string */
|
||||
rd[0] = 0;
|
||||
*len = 1;
|
||||
return LDNS_WIREPARSE_ERR_OK;
|
||||
}
|
||||
if(s[0] == '+') {
|
||||
rd[0] = 1; /* E.164 format */
|
||||
/* digits '0'..'9', with skipped dots. */
|
||||
s++;
|
||||
while(*s) {
|
||||
if(isspace((unsigned char)*s) || *s == '.') {
|
||||
s++;
|
||||
continue;
|
||||
}
|
||||
if(*s < '0' || *s > '9')
|
||||
return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX, s-str);
|
||||
if(*len < dlen + 2)
|
||||
return RET_ERR(LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL,
|
||||
s-str);
|
||||
rd[dlen+1] = *s++;
|
||||
dlen++;
|
||||
}
|
||||
*len = dlen+1;
|
||||
return LDNS_WIREPARSE_ERR_OK;
|
||||
}
|
||||
|
||||
rd[0] = 0; /* AESA format */
|
||||
/* hex, with skipped dots. */
|
||||
while(*s) {
|
||||
if(isspace((unsigned char)*s) || *s == '.') {
|
||||
s++;
|
||||
|
|
@ -2567,17 +2595,17 @@ int sldns_str2wire_atma_buf(const char* str, uint8_t* rd, size_t* len)
|
|||
}
|
||||
if(!isxdigit((unsigned char)*s))
|
||||
return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_HEX, s-str);
|
||||
if(*len < dlen/2 + 1)
|
||||
if(*len < dlen/2 + 2)
|
||||
return RET_ERR(LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL,
|
||||
s-str);
|
||||
if((dlen&1)==0)
|
||||
rd[dlen/2] = (uint8_t)sldns_hexdigit_to_int(*s++) * 16;
|
||||
else rd[dlen/2] += sldns_hexdigit_to_int(*s++);
|
||||
rd[dlen/2 + 1] = (uint8_t)sldns_hexdigit_to_int(*s++) * 16;
|
||||
else rd[dlen/2 + 1] += sldns_hexdigit_to_int(*s++);
|
||||
dlen++;
|
||||
}
|
||||
if((dlen&1)!=0)
|
||||
return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_HEX, s-str);
|
||||
*len = dlen/2;
|
||||
*len = dlen/2 + 1;
|
||||
return LDNS_WIREPARSE_ERR_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1870,7 +1870,33 @@ int sldns_wire2str_nsap_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
|
|||
|
||||
int sldns_wire2str_atma_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
|
||||
{
|
||||
return print_remainder_hex("", d, dl, s, sl);
|
||||
uint8_t format;
|
||||
int w = 0;
|
||||
size_t i;
|
||||
|
||||
if(*dl < 1) return -1;
|
||||
format = (*d)[0];
|
||||
(*d)+=1;
|
||||
(*dl)-=1;
|
||||
|
||||
if(format == 0) {
|
||||
/* AESA format (ATM End System Address). */
|
||||
return print_remainder_hex("", d, dl, s, sl);
|
||||
} else if(format == 1) {
|
||||
/* E.164 format. */
|
||||
w += sldns_str_print(s, sl, "+");
|
||||
for(i=0; i<*dl; i++) {
|
||||
if((*d)[i] < '0' || (*d)[0] > '9')
|
||||
return -1;
|
||||
w += sldns_str_print(s, sl, "%c", (*d)[i]);
|
||||
}
|
||||
(*d) += *dl;
|
||||
(*dl) = 0;
|
||||
} else {
|
||||
/* Unknown format. */
|
||||
return -1;
|
||||
}
|
||||
return w;
|
||||
}
|
||||
|
||||
/* internal scan routine that can modify arguments on failure */
|
||||
|
|
|
|||
3
testdata/test_ldnsrr.4
vendored
3
testdata/test_ldnsrr.4
vendored
|
|
@ -35,7 +35,8 @@ all.rr.org. IN LOC 42N 71 06 18.3W -24m 30m
|
|||
; EID
|
||||
; NIMLOC
|
||||
_http._tcp.all.rr.org. IN SRV 0 5 80 ns1.example.com.
|
||||
; ATMA
|
||||
atma0 IN ATMA 39.246f.00.0e7c9c.0312.0001.0001.000012345678.00
|
||||
atma1 IN ATMA +1.908.555.1212
|
||||
all.rr.org. IN NAPTR 100 10 "" "" "!^urn:cid:.+@([^\\.]+\\.)(.*)$!\\2!i" .
|
||||
all.rr.org. IN KX 2 rt1.example.com.
|
||||
all.rr.org. IN CERT 6 0 0 FFsAyW1dVK7hIGuvhN56r26UwJx/
|
||||
|
|
|
|||
4
testdata/test_ldnsrr.c4
vendored
4
testdata/test_ldnsrr.c4
vendored
|
|
@ -46,6 +46,10 @@ all.rr.org. 3600 IN LOC 42 21 54.500 N 71 06 18.300 W -24m 30m 10000m 10m
|
|||
all.rr.org. 3600 IN LOC 42 00 00.000 N 71 06 18.300 W -24m 30m 10000m 10m
|
||||
055F68747470045F74637003616C6C027272036F7267000021000100000E100017000000050050036E7331076578616D706C6503636F6D00
|
||||
_http._tcp.all.rr.org. 3600 IN SRV 0 5 80 ns1.example.com.
|
||||
0561746D6130000022000100000E1000150039246F000E7C9C03120001000100001234567800
|
||||
atma0. 3600 IN ATMA 39246F000E7C9C03120001000100001234567800
|
||||
0561746D6131000022000100000E10000C013139303835353531323132
|
||||
atma1. 3600 IN ATMA +19085551212
|
||||
03616C6C027272036F7267000023000100000E1000290064000A000021215E75726E3A6369643A2E2B40285B5E5C2E5D2B5C2E29282E2A2924215C32216900
|
||||
all.rr.org. 3600 IN NAPTR 100 10 "" "" "!^urn:cid:.+@([^\\.]+\\.)(.*)$!\\2!i" .
|
||||
03616C6C027272036F7267000024000100000E100013000203727431076578616D706C6503636F6D00
|
||||
|
|
|
|||
Loading…
Reference in a new issue