]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- First fix for zero b64 and hex text zone format in sldns.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 26 Jun 2017 11:36:54 +0000 (11:36 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 26 Jun 2017 11:36:54 +0000 (11:36 +0000)
git-svn-id: file:///svn/unbound/trunk@4247 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
sldns/str2wire.c
sldns/wire2str.c

index 937bb866b10821e939be3a52dd7067fa7e1c9e51..95f197c0f808f0df81957c36170eae8cea2f559b 100644 (file)
@@ -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).
index b4f84faf9b3b9c2c619f32083b3af087a3e83f2c..0e5145888b9d51c927666922650c690badb43b9f 100644 (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));
        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)
index ef505780f454df62be113d6232741976723d5796..c1162e7bab8ee3761eac79e7fac599559cc4686c 100644 (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)
 {
+       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);
 }