- First fix for zero b64 and hex text zone format in sldns.

git-svn-id: file:///svn/unbound/trunk@4247 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2017-06-26 11:36:54 +00:00
parent e7260518ea
commit 542162b4e0
3 changed files with 15 additions and 0 deletions

View file

@ -1,5 +1,6 @@
26 June 2017: Wouter 26 June 2017: Wouter
- Better fixup of dnscrypt_cert_chacha test for different escapes. - Better fixup of dnscrypt_cert_chacha test for different escapes.
- First fix for zero b64 and hex text zone format in sldns.
23 June 2017: Wouter 23 June 2017: Wouter
- (for 1.6.5): fixup of dnscrypt_cert_chacha test (from Manu Bretelle). - (for 1.6.5): fixup of dnscrypt_cert_chacha test (from Manu Bretelle).

View file

@ -1190,6 +1190,10 @@ int sldns_str2wire_b64_buf(const char* str, uint8_t* rd, size_t* len)
{ {
size_t sz = sldns_b64_pton_calculate_size(strlen(str)); size_t sz = sldns_b64_pton_calculate_size(strlen(str));
int n; int n;
if(strcmp(str, "0") == 0) {
*len = 0;
return LDNS_WIREPARSE_ERR_OK;
}
if(*len < sz) if(*len < sz)
return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
n = sldns_b64_pton(str, rd, *len); n = sldns_b64_pton(str, rd, *len);
@ -1223,6 +1227,10 @@ int sldns_str2wire_hex_buf(const char* str, uint8_t* rd, size_t* len)
s++; s++;
continue; continue;
} }
if(dlen == 0 && *s == '0' && *(s+1) == 0) {
*len = 0;
return LDNS_WIREPARSE_ERR_OK;
}
if(!isxdigit((unsigned char)*s)) if(!isxdigit((unsigned char)*s))
return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_HEX, s-str); return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_HEX, s-str);
if(*len < dlen/2 + 1) if(*len < dlen/2 + 1)

View file

@ -1220,11 +1220,17 @@ static int sldns_wire2str_b64_scan_num(uint8_t** d, size_t* dl, char** s,
int sldns_wire2str_b64_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) int sldns_wire2str_b64_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
{ {
if(*dl == 0) {
return sldns_str_print(s, sl, "0");
}
return sldns_wire2str_b64_scan_num(d, dl, s, sl, *dl); return sldns_wire2str_b64_scan_num(d, dl, s, sl, *dl);
} }
int sldns_wire2str_hex_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) int sldns_wire2str_hex_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
{ {
if(*dl == 0) {
return sldns_str_print(s, sl, "0");
}
return print_remainder_hex("", d, dl, s, sl); return print_remainder_hex("", d, dl, s, sl);
} }