From 542162b4e0b399b8078dd96765a7a1b925e70a00 Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Mon, 26 Jun 2017 11:36:54 +0000 Subject: [PATCH] - 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 --- doc/Changelog | 1 + sldns/str2wire.c | 8 ++++++++ sldns/wire2str.c | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/doc/Changelog b/doc/Changelog index 937bb866b..95f197c0f 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,5 +1,6 @@ 26 June 2017: Wouter - 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 - (for 1.6.5): fixup of dnscrypt_cert_chacha test (from Manu Bretelle). diff --git a/sldns/str2wire.c b/sldns/str2wire.c index b4f84faf9..0e5145888 100644 --- a/sldns/str2wire.c +++ b/sldns/str2wire.c @@ -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)); int n; + if(strcmp(str, "0") == 0) { + *len = 0; + return LDNS_WIREPARSE_ERR_OK; + } if(*len < sz) return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; 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++; continue; } + if(dlen == 0 && *s == '0' && *(s+1) == 0) { + *len = 0; + return LDNS_WIREPARSE_ERR_OK; + } if(!isxdigit((unsigned char)*s)) return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_HEX, s-str); if(*len < dlen/2 + 1) diff --git a/sldns/wire2str.c b/sldns/wire2str.c index ef505780f..c1162e7ba 100644 --- a/sldns/wire2str.c +++ b/sldns/wire2str.c @@ -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) { + if(*dl == 0) { + return sldns_str_print(s, sl, "0"); + } 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) { + if(*dl == 0) { + return sldns_str_print(s, sl, "0"); + } return print_remainder_hex("", d, dl, s, sl); } -- 2.47.3