Branch Coverage

src/ldns/rr.c
Criterion Covered Total %
branch 244 568 42.9


line true false branch
28 0 645 if (!rr) {
49 0 0 if (!rr) {
56 0 0 if(!rr->_rdata_fields) {
60 0 0 for (i = 0; i < ldns_rr_descriptor_minimum(desc); i++) {
78 644 75 if (rr) {
79 644 0 if (ldns_rr_owner(rr)) {
82 1459 644 for (i = 0; i < ldns_rr_rd_count(rr); i++) {
94 106 2 return rdf_type == LDNS_RDF_TYPE_STR ||
0 106 return rdf_type == LDNS_RDF_TYPE_STR ||
165 55 0 if (rr_buf) {
168 55 0 if (rd_buf) {
171 55 0 if (!new || !owner || !ttl || !clas || !rdata ||
55 0 if (!new || !owner || !ttl || !clas || !rdata ||
55 0 if (!new || !owner || !ttl || !clas || !rdata ||
55 0 if (!new || !owner || !ttl || !clas || !rdata ||
55 0 if (!new || !owner || !ttl || !clas || !rdata ||
55 0 if (!new || !owner || !ttl || !clas || !rdata ||
172 55 0 !rr_buf || !rd_buf || !rd || !xtok) {
55 0 !rr_buf || !rd_buf || !rd || !xtok) {
55 0 !rr_buf || !rd_buf || !rd || !xtok) {
180 0 55 if (ldns_bget_token(rr_buf, owner, "\t\n ", LDNS_MAX_DOMAINLEN) == -1){
186 0 55 if (ldns_bget_token(rr_buf, ttl, "\t\n ", LDNS_TTL_DATALEN) == -1) {
193 55 0 if (strlen(ttl) > 0 && !isdigit((int) ttl[0])) {
43 12 if (strlen(ttl) > 0 && !isdigit((int) ttl[0])) {
195 27 16 if (default_ttl == 0) {
209 15 28 if (clas_val == 0) {
212 0 15 if (!type) {
218 0 12 if (-1 == ldns_bget_token(
228 0 12 if (clas_val == 0) {
231 0 0 if (!type) {
239 40 15 if (!type) {
241 0 40 if (!type) {
244 0 40 if (-1 == ldns_bget_token(
259 5 50 if (strlen(owner) <= 1 && strncmp(owner, "@", 1) == 0) {
0 5 if (strlen(owner) <= 1 && strncmp(owner, "@", 1) == 0) {
260 0 0 if (origin) {
262 0 0 } else if (prev && *prev) {
0 0 } else if (prev && *prev) {
270 0 0 if (prev) {
273 0 0 if (!*prev) {
278 5 50 if (strlen(owner) == 0) {
281 5 0 if (prev && *prev) {
5 0 if (prev && *prev) {
283 0 0 } else if (origin) {
289 0 5 if(!ldns_rr_owner(new)) {
294 0 50 if (!owner_dname) {
300 38 12 if (!ldns_dname_str_absolute(owner) && origin) {
11 27 if (!ldns_dname_str_absolute(owner) && origin) {
301 0 11 if(ldns_dname_cat(ldns_rr_owner(new), origin)
308 11 39 if (prev) {
311 0 11 if (!*prev) {
332 55 0 if (desc) {
341 161 2 for (done = false, r_cnt = 0; !done && r_cnt < r_max; r_cnt++) {
108 53 for (done = false, r_cnt = 0; !done && r_cnt < r_max; r_cnt++) {
344 7 101 switch (ldns_rr_descriptor_field_type(desc, r_cnt)) {
350 7 0 case LDNS_RDF_TYPE_NSEC : if (r_cnt == r_max - 1) {
357 2 106 if (ldns_rdf_type_maybe_quoted(
359 2 0 desc, r_cnt)) &&
363 0 2 while (*(ldns_buffer_current(rd_buf)) == ' ') {
367 2 0 if (*(ldns_buffer_current(rd_buf)) == '\"') {
379 108 0 while (ldns_buffer_position(rd_buf) < ldns_buffer_limit(rd_buf)
380 0 108 && *(ldns_buffer_current(rd_buf)) == ' '
381 0 0 && !quoted) {
387 0 108 if (-1 == (c = ldns_bget_token(
400 0 108 if (strncmp(rd, "\\#", 2) == 0 && !quoted &&
0 0 if (strncmp(rd, "\\#", 2) == 0 && !quoted &&
0 0 if (strncmp(rd, "\\#", 2) == 0 && !quoted &&
401 0 0 (rd_strlen == 2 || rd[2]==' ')) {
414 0 0 if (c == -1) {
422 0 0 if (!hex_data_str) {
427 0 0 while(cur_hex_data_size < 2 * hex_data_size) {
430 0 0 if (c != -1) {
433 0 0 if (c == -1 ||
0 0 if (c == -1 ||
449 0 0 if (desc) {
454 0 0 if (!hex_data) {
462 0 0 if (status != LDNS_STATUS_OK) {
469 0 0 if (!r) {
473 0 0 if (!ldns_rr_push_rdf(new, r)) {
479 0 108 } else if(rd_strlen > 0 || quoted) {
0 0 } else if(rd_strlen > 0 || quoted) {
489 4 0 if (r_cnt == r_max - 1) {
492 0 4 if (c != -1) {
515 0 0 if (ldns_bget_token(rd_buf,
528 0 0 if (ldns_bget_token(rd_buf,
554 24 0 if (r && ldns_rdf_size(r) > 1 &&
555 0 8 ldns_rdf_data(r)[0] == 1 &&
562 0 0 : ( rr_type == LDNS_RR_TYPE_SOA ?
567 0 0 : ldns_rdf_new_frm_str(
571 24 0 } else if (r && rd_strlen >= 1 && origin &&
24 0 } else if (r && rd_strlen >= 1 && origin &&
575 0 1 if (status != LDNS_STATUS_OK) {
586 0 108 if (!r) {
592 2 106 if (quoted) {
593 0 2 if (ldns_buffer_available(rd_buf, 1)) {
607 55 0 if (!question && desc && !was_unknown_rr_format &&
55 0 if (!question && desc && !was_unknown_rr_format &&
614 55 0 if (newrr) {
625 0 0 if (rd_buf && rd_buf->_data) {
0 0 if (rd_buf && rd_buf->_data) {
630 0 0 if (rr_buf && rr_buf->_data) {
0 0 if (rr_buf && rr_buf->_data) {
679 34 0 for (s = line; *s && isspace(*s); s++)
15 19 for (s = line; *s && isspace(*s); s++)
682 29 1 for (e = strchr(s, 0); e > s+2 && isspace(e[-1]) && e[-2] != '\\'; e--)
11 18 for (e = strchr(s, 0); e > s+2 && isspace(e[-1]) && e[-2] != '\\'; e--)
11 0 for (e = strchr(s, 0); e > s+2 && isspace(e[-1]) && e[-2] != '\\'; e--)
706 19 0 if (default_ttl) {
713 0 19 if (!line) {
718 0 19 if ((size = ldns_fget_token_l(fp, line, LDNS_PARSE_SKIP_SPACE, LDNS_MAX_LINELEN, line_nr)) == -1) {
730 0 19 if (size == 0) {
735 2 17 if (strncmp(line, "$ORIGIN", 7) == 0 && isspace(line[7])) {
2 0 if (strncmp(line, "$ORIGIN", 7) == 0 && isspace(line[7])) {
736 2 0 if (*origin) {
742 0 2 if (!tmp) {
749 1 16 } else if (strncmp(line, "$TTL", 4) == 0 && isspace(line[4])) {
1 0 } else if (strncmp(line, "$TTL", 4) == 0 && isspace(line[4])) {
750 1 0 if (default_ttl) {
755 0 16 } else if (strncmp(line, "$INCLUDE", 8) == 0) {
757 0 16 } else if (!*ldns_strip_ws(line)) {
761 16 0 if (origin && *origin) {
16 0 if (origin && *origin) {
768 16 3 if (s == LDNS_STATUS_OK) {
769 16 0 if (newrr) {
822 0 0 if (position < rd_count) {
843 0 1466 if (!rdata_fields) {
864 0 0 if (rd_count == 0) {
871 0 0 if(rd_count > 1) {
874 0 0 if(newrd)
887 3444 0 if (rr && nr < ldns_rr_rd_count(rr)) {
3441 3 if (rr && nr < ldns_rr_rd_count(rr)) {
935 2831 0 if (rr_list) {
947 0 0 if (count > ldns_rr_list_rr_count(rr_list)) {
968 855 0 if (nr < ldns_rr_list_rr_count(rr_list)) {
979 0 424 if(!rr_list) return NULL;
989 30 0 if (rr_list) {
1000 394 0 if (rr_list) {
1001 499 394 for (i=0; i < ldns_rr_list_rr_count(rr_list); i++) {
1017 0 4 if (!left) {
1021 4 0 if (right) {
1028 4 4 for(i = 0; i < r_rr_count; i++) {
1042 6 0 if (left) {
1048 6 0 if (right) {
1056 0 6 if (!cat) {
1061 4 6 for(i = 0; i < l_rr_count; i++) {
1066 2 6 for(i = 0; i < r_rr_count; i++) {
1082 0 0 for(i = 0; i < ldns_rr_list_rr_count(l); i++) {
1086 0 0 if (!list_rdf) {
1092 0 0 if (ldns_rdf_compare(list_rdf, r) == 0) {
1099 0 0 if (ldns_rr_list_rr_count(subtyped) > 0) {
1117 206 322 if(rr_count+1 > cap) {
1120 177 29 if(cap == 0)
1124 0 206 if (!rrs) {
1143 0 0 for(i = 0; i < ldns_rr_list_rr_count(push_list); i++) {
1144 0 0 if (!ldns_rr_list_push_rr(rr_list,
1161 2 4 if (rr_count == 0) {
1169 0 4 if(cap > LDNS_RRLIST_INIT && rr_count-1 <= cap/2) {
0 0 if(cap > LDNS_RRLIST_INIT && rr_count-1 <= cap/2) {
1173 0 0 if(a) {
1194 0 0 if (!popped) {
1199 0 0 while(i > 0 &&
0 0 while(i > 0 &&
1205 0 0 if (i == howmany) { /* so i <= 0 */
1219 3 0 if (!rr_list || !rr || ldns_rr_list_rr_count(rr_list) == 0) {
3 0 if (!rr_list || !rr || ldns_rr_list_rr_count(rr_list) == 0) {
1 2 if (!rr_list || !rr || ldns_rr_list_rr_count(rr_list) == 0) {
1223 2 1 for (i = 0; i < ldns_rr_list_rr_count(rr_list); i++) {
1224 0 2 if (rr == ldns_rr_list_rr(rr_list, i)) {
1226 1 1 } else if (ldns_rr_compare(rr, ldns_rr_list_rr(rr_list, i)) == 0) {
1242 3 0 if (!rr_list || ldns_rr_list_rr_count(rr_list) == 0) {
1 2 if (!rr_list || ldns_rr_list_rr_count(rr_list) == 0) {
1253 3 1 for (i = 1; i < ldns_rr_list_rr_count(rr_list); i++) {
1255 0 3 if (t != ldns_rr_get_type(tmp)) {
1258 0 3 if (c != ldns_rr_get_class(tmp)) {
1261 1 2 if (ldns_rdf_compare(o, ldns_rr_owner(tmp)) != 0) {
1279 0 0 if (rr_count == 0) {
1287 0 0 if (ldns_rr_get_class(last) != ldns_rr_get_class(rr)) {
1290 0 0 if (ldns_rr_get_type(last) != ldns_rr_get_type(rr)) {
1294 0 0 if (ldns_rr_get_type(rr) != LDNS_RR_TYPE_RRSIG) {
1295 0 0 if (ldns_rr_ttl(last) != ldns_rr_ttl(rr)) {
1299 0 0 if (ldns_rdf_compare(ldns_rr_owner(last),
1305 0 0 for(i = 0; i < rr_count; i++) {
1306 0 0 if(ldns_rr_compare(
1329 0 0 if (!rr_list) {
1334 0 0 if (!last_rr) {
1336 0 0 if (!last_rr) {
1344 0 0 if (ldns_rr_list_rr_count(rr_list) > 0) {
1350 0 0 while (next_rr) {
1351 0 0 if (
1354 0 0 &&
1356 0 0 &&
1360 0 0 if (ldns_rr_list_rr_count(rr_list) > 0) {
1380 17 274 if (!rr) {
1385 0 274 if (!new_rr) {
1388 274 0 if (ldns_rr_owner(rr)) {
1396 641 274 for (i = 0; i < ldns_rr_rd_count(rr); i++) {
1397 641 0 if (ldns_rr_rdf(rr,i)) {
1412 0 79 if (!rrlist) {
1417 0 79 if (!new_list) {
1420 152 79 for (i = 0; i < ldns_rr_list_rr_count(rrlist); i++) {
1424 0 152 if (!r) {
1454 0 0 if (result == 0) {
1455 0 0 if (!sa->transformed_object) {
1459 0 0 if (ldns_rr2buffer_wire(sa->transformed_object, canonical_a, LDNS_SECTION_ANY) != LDNS_STATUS_OK) {
1467 0 0 if (!sb->transformed_object) {
1471 0 0 if (ldns_rr2buffer_wire(sb->transformed_object, canonical_b, LDNS_SECTION_ANY) != LDNS_STATUS_OK) {
1497 5 0 if (unsorted) {
1502 0 5 if(!sortables) return; /* no way to return error */
1503 5 5 for (i = 0; i < item_count; i++) {
1505 0 5 if(!sortables[i]) {
1507 0 0 while(i>0) {
1522 5 5 for (i = 0; i < item_count; i++) {
1524 0 5 if (sortables[i]->transformed_object) {
1546 2 14 if (ldns_dname_compare(ldns_rr_owner(rr1), ldns_rr_owner(rr2)) < 0) {
1548 2 12 } else if (ldns_dname_compare(ldns_rr_owner(rr1), ldns_rr_owner(rr2)) > 0) {
1553 0 12 if (ldns_rr_get_class(rr1) != ldns_rr_get_class(rr2)) {
1558 3 9 if (ldns_rr_get_type(rr1) != ldns_rr_get_type(rr2)) {
1565 9 0 if (offset > rr1_len || offset > rr2_len) {
0 9 if (offset > rr1_len || offset > rr2_len) {
1566 0 0 if (rr1_len == rr2_len) {
1585 26 0 while (offset < rr1_len && *ldns_buffer_at(rr1_buf, offset) != 0) {
17 9 while (offset < rr1_len && *ldns_buffer_at(rr1_buf, offset) != 0) {
1593 298 9 for(i = offset; i < min_len; i++) {
1594 0 298 if (*ldns_buffer_at(rr1_buf,i) < *ldns_buffer_at(rr2_buf,i)) {
1596 0 298 } else if (*ldns_buffer_at(rr1_buf,i) > *ldns_buffer_at(rr2_buf,i)) {
1602 0 9 if (rr1_len < rr2_len) {
1604 0 9 } else if (rr1_len > rr2_len) {
1622 9 7 if (result == 0) {
1629 0 9 if (ldns_rr2buffer_wire_canonical(rr1_buf,
1637 0 9 if (ldns_rr2buffer_wire_canonical(rr2_buf,
1665 6 0 if (!dnskey || !ds ||
1666 0 6 ldns_rr_get_type(ds) != LDNS_RR_TYPE_DS ||
1671 0 6 if (ldns_rr_rdf(ds, 2) == NULL) {
1677 6 0 if (ds_gen) {
1720 0 0 for (i = 0; i < ldns_rr_list_rr_count(rrl1) && i < ldns_rr_list_rr_count(rrl2); i++) {
0 0 for (i = 0; i < ldns_rr_list_rr_count(rrl1) && i < ldns_rr_list_rr_count(rrl2); i++) {
1722 0 0 if (rr_cmp != 0) {
1746 158 50 for(i = 0; i < ldns_rr_rd_count(r); i++) {
1760 0 7 if (!rr) {
1773 5 2 switch(ldns_rr_get_type(rr)) {
1797 35 5 for (i = 0; i < ldns_rr_rd_count(rr); i++) {
1811 0 0 for (i = 0; i < ldns_rr_list_rr_count(rr_list); i++) {
1819 0 0 if (!rr) {
2495 0 0 for (d=rdata_field_descriptors; d < rdata_field_descriptors_end; d++) {
2498 0 0 if (windows[window] < subtype) {
2506 0 0 for (i = 0; i < 256; i++) {
2507 0 0 if (windows[i]) {
2511 0 0 if (sz > 0) {
2516 0 0 if (!data) {
2519 0 0 for (i = 0; i < 256; i++) {
2520 0 0 if (windows[i]) {
2530 0 0 if (!*rdf) {
2556 563 0 if (type < LDNS_RDATA_FIELD_DESCRIPTORS_COMMON) {
2560 0 0 for (i = LDNS_RDATA_FIELD_DESCRIPTORS_COMMON;
2563 0 0 if (rdata_field_descriptors[i]._type == type) {
2574 55 0 if (descriptor) {
2584 732 0 if (descriptor) {
2585 5 727 if (descriptor->_variable != LDNS_RDF_TYPE_NONE) {
2603 1098 11 if (index < descriptor->_maximum) {
2618 15 75 if (strlen(name) > 4 && strncasecmp(name, "TYPE", 4) == 0) {
0 15 if (strlen(name) > 4 && strncasecmp(name, "TYPE", 4) == 0) {
2623 1968 1 for (i = 0; i < (unsigned int) LDNS_RDATA_FIELD_DESCRIPTORS_COUNT; i++) {
2626 1878 90 if(desc_name &&
314 1564 if(desc_name &&
2627 89 225 strlen(name) == strlen(desc_name) &&
2635 0 1 if (strlen(name) == 4 && strncasecmp(name, "IXFR", 4) == 0) {
0 0 if (strlen(name) == 4 && strncasecmp(name, "IXFR", 4) == 0) {
2637 0 1 } else if (strlen(name) == 4 && strncasecmp(name, "AXFR", 4) == 0) {
0 0 } else if (strlen(name) == 4 && strncasecmp(name, "AXFR", 4) == 0) {
2639 0 1 } else if (strlen(name) == 5 && strncasecmp(name, "MAILB", 5) == 0) {
0 0 } else if (strlen(name) == 5 && strncasecmp(name, "MAILB", 5) == 0) {
2641 0 1 } else if (strlen(name) == 5 && strncasecmp(name, "MAILA", 5) == 0) {
0 0 } else if (strlen(name) == 5 && strncasecmp(name, "MAILA", 5) == 0) {
2643 0 1 } else if (strlen(name) == 3 && strncasecmp(name, "ANY", 3) == 0) {
0 0 } else if (strlen(name) == 3 && strncasecmp(name, "ANY", 3) == 0) {
2656 1 80 if (strlen(name) > 5 && strncasecmp(name, "CLASS", 5) == 0) {
0 1 if (strlen(name) > 5 && strncasecmp(name, "CLASS", 5) == 0) {
2663 65 16 if (lt) {
2675 0 5 if (!rd) {
2679 0 5 if (ldns_rdf_get_type(rd) != LDNS_RDF_TYPE_TYPE) {
2690 0 0 if (rr_list && ldns_rr_list_rr_count(rr_list) > 0) {
0 0 if (rr_list && ldns_rr_list_rr_count(rr_list) > 0) {
2700 0 0 if (rr_list && ldns_rr_list_rr_count(rr_list) > 0) {
0 0 if (rr_list && ldns_rr_list_rr_count(rr_list) > 0) {