Branch Coverage

src/ldns/str2host.c
Criterion Covered Total %
branch 88 522 16.8


line true false branch
41 0 11 if(!r) return LDNS_STATUS_MEM_ERR;
45 0 11 if(*end != 0) {
52 11 0 return *rd?LDNS_STATUS_OK:LDNS_STATUS_MEM_ERR;
67 0 2 if(!r) return LDNS_STATUS_MEM_ERR;
71 2 0 if (strlen(time) == 14 &&
2 0 if (strlen(time) == 14 &&
77 0 2 if (tm.tm_year < 70) {
80 2 0 if (tm.tm_mon < 0 || tm.tm_mon > 11) {
2 0 if (tm.tm_mon < 0 || tm.tm_mon > 11) {
83 2 0 if (tm.tm_mday < 1 || tm.tm_mday > 31) {
2 0 if (tm.tm_mday < 1 || tm.tm_mday > 31) {
87 2 0 if (tm.tm_hour < 0 || tm.tm_hour > 23) {
2 0 if (tm.tm_hour < 0 || tm.tm_hour > 23) {
91 2 0 if (tm.tm_min < 0 || tm.tm_min > 59) {
2 0 if (tm.tm_min < 0 || tm.tm_min > 59) {
95 2 0 if (tm.tm_sec < 0 || tm.tm_sec > 59) {
2 0 if (tm.tm_sec < 0 || tm.tm_sec > 59) {
104 2 0 return *rd?LDNS_STATUS_OK:LDNS_STATUS_MEM_ERR;
108 0 0 if(*end != 0) {
116 0 0 return *rd?LDNS_STATUS_OK:LDNS_STATUS_MEM_ERR;
134 0 3 if(rd == NULL) {
139 2 1 if (salt_length_str == 1 && salt_str[0] == '-') {
2 0 if (salt_length_str == 1 && salt_str[0] == '-') {
141 0 1 } else if (salt_length_str % 2 != 0) {
144 0 3 if (salt_length_str > 512) {
149 0 3 if(!salt) {
152 8 3 for (c = 0; c < salt_length_str; c += 2) {
153 8 0 if (isxdigit((int) salt_str[c]) && isxdigit((int) salt_str[c+1])) {
8 0 if (isxdigit((int) salt_str[c]) && isxdigit((int) salt_str[c+1])) {
164 0 3 if(!data) {
174 3 0 return *rd?LDNS_STATUS_OK:LDNS_STATUS_MEM_ERR;
186 0 12 if (*end != 0) {
193 12 0 return *rd?LDNS_STATUS_OK:LDNS_STATUS_MEM_ERR;
204 0 4 if(!r) return LDNS_STATUS_MEM_ERR;
207 0 4 if(*longstr == '-')
211 0 4 if(*end != 0) {
215 0 4 if (errno == ERANGE) {
223 4 0 return *rd?LDNS_STATUS_OK:LDNS_STATUS_MEM_ERR;
234 0 14 if(!r) return LDNS_STATUS_MEM_ERR;
238 0 14 if(*end != 0) {
245 14 0 return *rd?LDNS_STATUS_OK:LDNS_STATUS_MEM_ERR;
265 0 0 if ((*str_p)[0] && isdigit((*str_p)[0]) &&
0 0 if ((*str_p)[0] && isdigit((*str_p)[0]) &&
0 0 if ((*str_p)[0] && isdigit((*str_p)[0]) &&
266 0 0 (*str_p)[1] && isdigit((*str_p)[1]) &&
0 0 (*str_p)[1] && isdigit((*str_p)[1]) &&
267 0 0 (*str_p)[2] && isdigit((*str_p)[2])) {
273 0 0 if (val > 255) {
280 0 0 } else if ((*str_p)[0] && !isdigit((*str_p)[0])) {
0 0 } else if ((*str_p)[0] && !isdigit((*str_p)[0])) {
322 0 116 if (len > LDNS_MAX_DOMAINLEN * 4) {
325 0 116 if (0 == len) {
330 5 111 if (1 == len && *str == '.') {
5 0 if (1 == len && *str == '.') {
346 1168 110 for (s = str; *s; s++, q++) {
347 0 1168 if (q > buf + LDNS_MAX_DOMAINLEN) {
353 0 141 if (label_len > LDNS_MAX_LABELLEN) {
356 1 140 if (label_len == 0) {
367 0 0 if (! parse_escape(q, &s)) {
380 80 30 if (!ldns_dname_str_absolute(str)) {
381 0 80 if (q > buf + LDNS_MAX_DOMAINLEN) {
384 0 80 if (label_len > LDNS_MAX_LABELLEN) {
387 0 80 if (label_len == 0) { /* label_len 0 but not . at end? */
404 1 39 if (inet_pton(AF_INET, (char*)str, &address) != 1) {
410 39 0 return *rd?LDNS_STATUS_OK:LDNS_STATUS_MEM_ERR;
418 7 25 if (inet_pton(AF_INET6, (char*)str, address) != 1) {
424 25 0 return *rd?LDNS_STATUS_OK:LDNS_STATUS_MEM_ERR;
434 2 0 dp = data = LDNS_XMALLOC(uint8_t, strlen(str) > 255 ? 256 : (strlen(str) + 1));
435 0 2 if (! data) {
440 141 2 while (parse_char(&ch, &str)) {
441 0 141 if (dp - data >= 255) {
447 0 2 if (! str) {
456 0 2 if (! data) {
463 0 2 if (! *rd) {
489 0 0 if (strlen(my_str) < 2
490 0 0 || strchr(my_str, ':') == NULL
491 0 0 || strchr(my_str, '/') == NULL
492 0 0 || strchr(my_str, ':') > strchr(my_str, '/')) {
496 0 0 if (my_str[0] == '!') {
510 0 0 if(!my_ip_str) return LDNS_STATUS_MEM_ERR;
514 0 0 if (family == 1) {
517 0 0 if(!afdpart) {
521 0 0 if (inet_pton(AF_INET, my_ip_str, afdpart) == 0) {
526 0 0 for (i = 0; i < 4; i++) {
527 0 0 if (afdpart[i] != 0) {
531 0 0 } else if (family == 2) {
534 0 0 if(!afdpart) {
538 0 0 if (inet_pton(AF_INET6, my_ip_str, afdpart) == 0) {
543 0 0 for (i = 0; i < 16; i++) {
544 0 0 if (afdpart[i] != 0) {
558 0 0 if(!data) {
566 0 0 if (negation) {
578 0 0 return *rd?LDNS_STATUS_OK:LDNS_STATUS_MEM_ERR;
588 0 4 if(!buffer) {
594 0 4 if (-1 == i) {
603 4 0 return *rd?LDNS_STATUS_OK:LDNS_STATUS_MEM_ERR;
614 0 2 if(!buffer) {
621 0 2 if (i < 0) {
630 2 0 return *rd?LDNS_STATUS_OK:LDNS_STATUS_MEM_ERR;
642 0 0 if (len > LDNS_MAX_RDFLEN * 2) {
646 0 0 if(!t) {
651 0 0 while (*str) {
653 0 0 if (isspace((int) *str)) {
656 0 0 for (i = 16; i >= 1; i -= 15) {
657 0 0 while (*str && isspace((int) *str)) { str++; }
0 0 while (*str && isspace((int) *str)) { str++; }
658 0 0 if (*str) {
659 0 0 if (isxdigit((int) *str)) {
676 0 0 return *rd?LDNS_STATUS_OK:LDNS_STATUS_MEM_ERR;
689 0 3 if(!token) return LDNS_STATUS_MEM_ERR;
690 0 3 if(rd == NULL) {
696 0 3 if(!str_buf) {
701 0 3 if(ldns_buffer_status(str_buf) != LDNS_STATUS_OK) {
707 9 3 while ((c = ldns_bget_token(str_buf, token, delimiters, LDNS_MAX_RDFLEN)) != -1 && c != 0) {
9 0 while ((c = ldns_bget_token(str_buf, token, delimiters, LDNS_MAX_RDFLEN)) != -1 && c != 0) {
708 0 9 if(type_count >= sizeof(type_list)) {
724 3 0 return *rd?LDNS_STATUS_OK:LDNS_STATUS_MEM_ERR;
735 1 0 return *rd?LDNS_STATUS_OK:LDNS_STATUS_MEM_ERR;
746 0 0 return *rd?LDNS_STATUS_OK:LDNS_STATUS_MEM_ERR;
761 0 0 if (lt) {
765 0 0 if (!*rd) {
805 0 4 if ((lt = ldns_lookup_by_name(lt, str))) {
808 0 0 if (!*rd)
869 0 0 while (isblank(*my_str)) {
873 0 0 if (*my_str == '.') {
877 0 0 if (meters >= 1) {
884 0 0 while(val >= 10) {
890 0 0 if (*e > 9)
892 0 0 if (*my_str == 'm' || *my_str == 'M') {
0 0 if (*my_str == 'm' || *my_str == 'M') {
922 0 0 if (isdigit((int) *my_str)) {
928 0 0 while (isblank((int) *my_str)) {
932 0 0 if (isdigit((int) *my_str)) {
934 0 0 } else if (*my_str == 'N' || *my_str == 'S') {
0 0 } else if (*my_str == 'N' || *my_str == 'S') {
940 0 0 while (isblank((int) *my_str)) {
944 0 0 if (isdigit((int) *my_str)) {
948 0 0 while (isblank((int) *my_str)) {
952 0 0 if (*my_str == 'N') {
954 0 0 } else if (*my_str == 'S') {
969 0 0 if (northerness) {
974 0 0 while (isblank(*my_str)) {
978 0 0 if (isdigit((int) *my_str)) {
984 0 0 while (isblank((int) *my_str)) {
988 0 0 if (isdigit((int) *my_str)) {
990 0 0 } else if (*my_str == 'E' || *my_str == 'W') {
0 0 } else if (*my_str == 'E' || *my_str == 'W') {
996 0 0 while (isblank(*my_str)) {
1000 0 0 if (isdigit((int) *my_str)) {
1005 0 0 while (isblank(*my_str)) {
1009 0 0 if (*my_str == 'E') {
1011 0 0 } else if (*my_str == 'W') {
1027 0 0 if (easterness) {
1035 0 0 if (*my_str == 'm' || *my_str == 'M') {
0 0 if (*my_str == 'm' || *my_str == 'M') {
1039 0 0 if (strlen(my_str) > 0) {
1040 0 0 if(!loc_parse_cm(my_str, &my_str, &size_b, &size_e))
1044 0 0 if (strlen(my_str) > 0) {
1045 0 0 if(!loc_parse_cm(my_str, &my_str, &horiz_pre_b, &horiz_pre_e))
1049 0 0 if (strlen(my_str) > 0) {
1050 0 0 if(!loc_parse_cm(my_str, &my_str, &vert_pre_b, &vert_pre_e))
1055 0 0 if(!data) {
1071 0 0 return *rd?LDNS_STATUS_OK:LDNS_STATUS_MEM_ERR;
1089 0 0 if(strlen(str) == 0)
1092 0 0 if(!token) return LDNS_STATUS_MEM_ERR;
1095 0 0 if(!str_buf) {LDNS_FREE(token); return LDNS_STATUS_MEM_ERR;}
1097 0 0 if(ldns_buffer_status(str_buf) != LDNS_STATUS_OK) {
1103 0 0 while(ldns_bget_token(str_buf, token, "\t\n ", strlen(str)) > 0) {
1104 0 0 if (!proto_str) {
1106 0 0 if (!proto_str) {
1114 0 0 if (serv) {
1119 0 0 if (serv_port / 8 >= bm_len) {
1121 0 0 if(!b2) {
1130 0 0 for (; bm_len <= serv_port / 8; bm_len++) {
1138 0 0 if (!proto_str || !bitmap) {
0 0 if (!proto_str || !bitmap) {
1147 0 0 if(!data) {
1154 0 0 if (proto_str)
1156 0 0 if (proto) {
1158 0 0 } else if (proto_str) {
1177 0 0 if(!*rd) return LDNS_STATUS_MEM_ERR;
1189 0 0 if (str[0] != '0' || str[1] != 'x') {
0 0 if (str[0] != '0' || str[1] != 'x') {
1193 0 0 for (i=0; i < len; i++) {
1194 0 0 if (nsap_str[i] == '.')
1210 0 0 for (i=0; i < len; i++) {
1211 0 0 if (atma_str[i] == '.')
1238 0 0 if(strlen(str) == 0)
1241 0 0 if(!token) return LDNS_STATUS_MEM_ERR;
1244 0 0 if(!str_buf) {LDNS_FREE(token); return LDNS_STATUS_MEM_ERR;}
1246 0 0 if(ldns_buffer_status(str_buf) != LDNS_STATUS_OK) {
1251 0 0 while(ldns_bget_token(str_buf, token, "\t\n ", strlen(str)) > 0) {
1264 0 0 if (!gateway || (gateway_type == 0 &&
0 0 if (!gateway || (gateway_type == 0 &&
0 0 if (!gateway || (gateway_type == 0 &&
1265 0 0 (token[0] != '.' || token[1] != '\0'))) {
1284 0 0 if (!gateway || !publickey) {
0 0 if (!gateway || !publickey) {
1285 0 0 if (gateway)
1287 0 0 if (publickey)
1294 0 0 if (gateway_type == 1) {
1296 0 0 } else if (gateway_type == 2) {
1298 0 0 } else if (gateway_type == 3) {
1302 0 0 if (status != LDNS_STATUS_OK) {
1303 0 0 if (gateway)
1305 0 0 if (publickey)
1314 0 0 if (status != LDNS_STATUS_OK) {
1315 0 0 if (gateway)
1317 0 0 if (publickey)
1321 0 0 if (gateway_rdf) ldns_rdf_free(gateway_rdf);
1326 0 0 if (gateway_type)
1332 0 0 if(!data) {
1333 0 0 if (gateway)
1335 0 0 if (publickey)
1339 0 0 if (gateway_rdf) ldns_rdf_free(gateway_rdf);
1340 0 0 if (publickey_rdf) ldns_rdf_free(publickey_rdf);
1348 0 0 if (gateway_type) {
1360 0 0 if (gateway)
1362 0 0 if (publickey)
1369 0 0 if(!*rd) return LDNS_STATUS_MEM_ERR;
1380 0 0 if (sscanf(str, "%4x:%4x:%4x:%4x%n", &a, &b, &c, &d, &l) != 4 ||
0 0 if (sscanf(str, "%4x:%4x:%4x:%4x%n", &a, &b, &c, &d, &l) != 4 ||
1381 0 0 l != (int)strlen(str) || /* more data to read */
1393 0 0 return *rd ? LDNS_STATUS_OK : LDNS_STATUS_MEM_ERR;
1403 0 0 if (sscanf(str, "%2x-%2x-%2x-%2x-%2x-%2x%n",
1404 0 0 &a, &b, &c, &d, &e, &f, &l) != 6 ||
1416 0 0 return *rd ? LDNS_STATUS_OK : LDNS_STATUS_MEM_ERR;
1426 0 0 if (sscanf(str, "%2x-%2x-%2x-%2x-%2x-%2x-%2x-%2x%n",
1427 0 0 &a, &b, &c, &d, &e, &f, &g, &h, &l) != 8 ||
1441 0 0 return *rd ? LDNS_STATUS_OK : LDNS_STATUS_MEM_ERR;
1450 0 0 if (strlen(str) > 255) {
1453 0 0 for (ptr = str; *ptr; ptr++) {
1454 0 0 if (! isalnum(*ptr)) {
1459 0 0 if (!data) {
1466 0 0 if (!*rd) {
1481 0 0 if (! data) {
1486 0 0 while (parse_char(&ch, &str)) {
1488 0 0 if (dp - data > LDNS_MAX_RDFLEN) {
1493 0 0 if (! str) {
1500 0 0 if (! data) {
1507 0 0 if (! *rd) {
1518 0 0 const char *pk = hit == NULL ? NULL : strchr(hit, ' ') + 1;
1520 0 0 : pk == NULL ? strlen(hit) : (size_t) (pk - hit) - 1;
0 0 : pk == NULL ? strlen(hit) : (size_t) (pk - hit) - 1;
1521 0 0 size_t pk_size = pk == NULL ? 0 : strlen(pk);
1532 0 0 if (hit_size == 0 || pk_size == 0 || (hit_size + 1) / 2 > 255
0 0 if (hit_size == 0 || pk_size == 0 || (hit_size + 1) / 2 > 255
0 0 if (hit_size == 0 || pk_size == 0 || (hit_size + 1) / 2 > 255
1533 0 0 || rdf_size > LDNS_MAX_RDFLEN
1534 0 0 || algorithm < 0 || algorithm > 255
0 0 || algorithm < 0 || algorithm > 255
1535 0 0 || (errno != 0 && algorithm == 0) /* out of range */
0 0 || (errno != 0 && algorithm == 0) /* out of range */
1536 0 0 || endptr == str /* no digits */) {
1540 0 0 if ((data = LDNS_XMALLOC(uint8_t, rdf_size)) == NULL) {
1574 0 0 for (dp = data + 4; *hit && *hit != ' '; dp++) {
0 0 for (dp = data + 4; *hit && *hit != ' '; dp++) {
1576 0 0 if ((hi = ldns_hexdigit_to_int(*hit++)) == -1 ||
0 0 if ((hi = ldns_hexdigit_to_int(*hit++)) == -1 ||
1584 0 0 if ((written = ldns_b64_pton(pk, dp, pk_wire_size)) <= 0) {
1598 0 0 if (! (*rd = ldns_rdf_new(LDNS_RDF_TYPE_HIP, rdf_size, data))) {