/* 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;
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;
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;
* @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.