]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- str2wire fp2rr returns line string for $directives.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 19 May 2017 08:54:37 +0000 (08:54 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 19 May 2017 08:54:37 +0000 (08:54 +0000)
git-svn-id: file:///svn/unbound/trunk@4176 be551aaa-1e26-0410-a405-d3ace91eadb9

sldns/str2wire.c
sldns/str2wire.h

index 9dbfdf71fa3ca5f474ce5b0fa43f62b9f2d7bc37..b4f84faf9b3b9c2c619f32083b3af087a3e83f2c 100644 (file)
@@ -869,6 +869,8 @@ int sldns_fp2wire_rr_buf(FILE* in, uint8_t* rr, size_t* len, size_t* dname_len,
        /* we can have the situation, where we've read ok, but still got
         * no bytes to play with, in this case size is 0 */
        if(size == 0) {
+               if(*len > 0)
+                       rr[0] = 0;
                *len = 0;
                *dname_len = 0;
                return LDNS_WIREPARSE_ERR_OK;
@@ -876,6 +878,7 @@ int sldns_fp2wire_rr_buf(FILE* in, uint8_t* rr, size_t* len, size_t* dname_len,
 
        if(strncmp(line, "$ORIGIN", 7) == 0 && isspace((unsigned char)line[7])) {
                int s;
+               strlcpy((char*)rr, line, *len);
                *len = 0;
                *dname_len = 0;
                if(!parse_state) return LDNS_WIREPARSE_ERR_OK;
@@ -886,12 +889,19 @@ int sldns_fp2wire_rr_buf(FILE* in, uint8_t* rr, size_t* len, size_t* dname_len,
                return s;
        } else if(strncmp(line, "$TTL", 4) == 0 && isspace((unsigned char)line[4])) {
                const char* end = NULL;
+               strlcpy((char*)rr, line, *len);
                *len = 0;
                *dname_len = 0;
                if(!parse_state) return LDNS_WIREPARSE_ERR_OK;
                parse_state->default_ttl = sldns_str2period(
                        sldns_strip_ws(line+5), &end);
        } else if (strncmp(line, "$INCLUDE", 8) == 0) {
+               strlcpy((char*)rr, line, *len);
+               *len = 0;
+               *dname_len = 0;
+               return LDNS_WIREPARSE_ERR_INCLUDE;
+       } else if (strncmp(line, "$", 1) == 0) {
+               strlcpy((char*)rr, line, *len);
                *len = 0;
                *dname_len = 0;
                return LDNS_WIREPARSE_ERR_INCLUDE;
index 9b2b35b371d0c2349312155fd8296e0881c0cfec..a0d6f55b03e83a0ad15058a010711fe8cc422492 100644 (file)
@@ -237,6 +237,8 @@ struct sldns_file_parse_state {
  * @param rr: this is malloced by the user and the result is stored here,
  *     if an RR is read.  If no RR is read this is signalled with the
  *     return len set to 0 (for ORIGIN, TTL directives).
+ *     The read line is available in the rr_buf (zero terminated), for
+ *     $DIRECTIVE style elements.
  * @param len: on input, the length of the rr buffer.  on output the rr len.
  *     Buffer size of 64k should be enough.
  * @param dname_len: returns the length of the dname initial part of the rr.