ares_malloc:
   70|   469k|{
   71|   469k|  return __ares_malloc(size);
   72|   469k|}
ares_realloc:
   75|   213k|{
   76|   213k|  return __ares_realloc(ptr, size);
   77|   213k|}
ares_free:
   80|   713k|{
   81|   713k|  __ares_free(ptr);
   82|   713k|}
ares_malloc_zero:
   85|   383k|{
   86|   383k|  void *ptr = ares_malloc(size);
   87|   383k|  if (ptr != NULL) {
  ------------------
  |  Branch (87:7): [True: 383k, False: 0]
  ------------------
   88|   383k|    memset(ptr, 0, size);
   89|   383k|  }
   90|       |
   91|   383k|  return ptr;
   92|   383k|}
ares_realloc_zero:
   95|  34.7k|{
   96|  34.7k|  void *p = ares_realloc(ptr, new_size);
   97|  34.7k|  if (p == NULL) {
  ------------------
  |  Branch (97:7): [True: 0, False: 34.7k]
  ------------------
   98|      0|    return NULL;
   99|      0|  }
  100|       |
  101|  34.7k|  if (new_size > orig_size) {
  ------------------
  |  Branch (101:7): [True: 34.7k, False: 0]
  ------------------
  102|  34.7k|    memset((unsigned char *)p + orig_size, 0, new_size - orig_size);
  103|  34.7k|  }
  104|       |
  105|  34.7k|  return p;
  106|  34.7k|}
ares_library_init.c:default_malloc:
   48|   469k|{
   49|   469k|  if (size == 0) {
  ------------------
  |  Branch (49:7): [True: 0, False: 469k]
  ------------------
   50|      0|    return NULL;
   51|      0|  }
   52|   469k|  return malloc(size);
   53|   469k|}
ares_library_init.c:default_realloc:
   56|   213k|{
   57|   213k|  return realloc(p, size);
   58|   213k|}
ares_library_init.c:default_free:
   61|   713k|{
   62|   713k|  free(p);
   63|   713k|}

ares_array_create:
   42|  41.5k|{
   43|  41.5k|  ares_array_t *arr;
   44|       |
   45|  41.5k|  if (member_size == 0) {
  ------------------
  |  Branch (45:7): [True: 0, False: 41.5k]
  ------------------
   46|      0|    return NULL;
   47|      0|  }
   48|       |
   49|  41.5k|  arr = ares_malloc_zero(sizeof(*arr));
   50|  41.5k|  if (arr == NULL) {
  ------------------
  |  Branch (50:7): [True: 0, False: 41.5k]
  ------------------
   51|      0|    return NULL;
   52|      0|  }
   53|       |
   54|  41.5k|  arr->member_size = member_size;
   55|  41.5k|  arr->destruct    = destruct;
   56|  41.5k|  return arr;
   57|  41.5k|}
ares_array_len:
   60|  1.18M|{
   61|  1.18M|  if (arr == NULL) {
  ------------------
  |  Branch (61:7): [True: 0, False: 1.18M]
  ------------------
   62|      0|    return 0;
   63|      0|  }
   64|  1.18M|  return arr->cnt;
   65|  1.18M|}
ares_array_at:
   68|   517k|{
   69|   517k|  if (arr == NULL || idx >= arr->cnt) {
  ------------------
  |  Branch (69:7): [True: 0, False: 517k]
  |  Branch (69:22): [True: 0, False: 517k]
  ------------------
   70|      0|    return NULL;
   71|      0|  }
   72|   517k|  return (unsigned char *)arr->arr + ((idx + arr->offset) * arr->member_size);
   73|   517k|}
ares_array_at_const:
   76|   220k|{
   77|   220k|  if (arr == NULL || idx >= arr->cnt) {
  ------------------
  |  Branch (77:7): [True: 0, False: 220k]
  |  Branch (77:22): [True: 0, False: 220k]
  ------------------
   78|      0|    return NULL;
   79|      0|  }
   80|   220k|  return (unsigned char *)arr->arr + ((idx + arr->offset) * arr->member_size);
   81|   220k|}
ares_array_destroy:
  100|  45.5k|{
  101|  45.5k|  size_t i;
  102|       |
  103|  45.5k|  if (arr == NULL) {
  ------------------
  |  Branch (103:7): [True: 3.98k, False: 41.5k]
  ------------------
  104|  3.98k|    return;
  105|  3.98k|  }
  106|       |
  107|  41.5k|  if (arr->destruct != NULL) {
  ------------------
  |  Branch (107:7): [True: 41.5k, False: 0]
  ------------------
  108|   123k|    for (i = 0; i < arr->cnt; i++) {
  ------------------
  |  Branch (108:17): [True: 81.8k, False: 41.5k]
  ------------------
  109|  81.8k|      arr->destruct(ares_array_at(arr, i));
  110|  81.8k|    }
  111|  41.5k|  }
  112|       |
  113|  41.5k|  ares_free(arr->arr);
  114|  41.5k|  ares_free(arr);
  115|  41.5k|}
ares_array_set_size:
  173|   297k|{
  174|   297k|  void *temp;
  175|       |
  176|   297k|  if (arr == NULL || size == 0 || size < arr->cnt) {
  ------------------
  |  Branch (176:7): [True: 0, False: 297k]
  |  Branch (176:22): [True: 0, False: 297k]
  |  Branch (176:35): [True: 0, False: 297k]
  ------------------
  177|      0|    return ARES_EFORMERR;
  178|      0|  }
  179|       |
  180|       |  /* Always operate on powers of 2 */
  181|   297k|  size = ares_round_up_pow2(size);
  182|       |
  183|   297k|  if (size < ARES__ARRAY_MIN) {
  ------------------
  |  |   29|   297k|#define ARES__ARRAY_MIN 4
  ------------------
  |  Branch (183:7): [True: 37.4k, False: 260k]
  ------------------
  184|  37.4k|    size = ARES__ARRAY_MIN;
  ------------------
  |  |   29|  37.4k|#define ARES__ARRAY_MIN 4
  ------------------
  185|  37.4k|  }
  186|       |
  187|       |  /* If our allocation size is already large enough, skip */
  188|   297k|  if (size <= arr->alloc_cnt) {
  ------------------
  |  Branch (188:7): [True: 262k, False: 34.7k]
  ------------------
  189|   262k|    return ARES_SUCCESS;
  190|   262k|  }
  191|       |
  192|  34.7k|  temp = ares_realloc_zero(arr->arr, arr->alloc_cnt * arr->member_size,
  193|  34.7k|                           size * arr->member_size);
  194|  34.7k|  if (temp == NULL) {
  ------------------
  |  Branch (194:7): [True: 0, False: 34.7k]
  ------------------
  195|      0|    return ARES_ENOMEM;
  196|      0|  }
  197|  34.7k|  arr->alloc_cnt = size;
  198|  34.7k|  arr->arr       = temp;
  199|  34.7k|  return ARES_SUCCESS;
  200|  34.7k|}
ares_array_insert_at:
  204|   294k|{
  205|   294k|  void         *ptr;
  206|   294k|  ares_status_t status;
  207|       |
  208|   294k|  if (arr == NULL) {
  ------------------
  |  Branch (208:7): [True: 0, False: 294k]
  ------------------
  209|      0|    return ARES_EFORMERR;
  210|      0|  }
  211|       |
  212|       |  /* Not >= since we are allowed to append to the end */
  213|   294k|  if (idx > arr->cnt) {
  ------------------
  |  Branch (213:7): [True: 0, False: 294k]
  ------------------
  214|      0|    return ARES_EFORMERR;
  215|      0|  }
  216|       |
  217|       |  /* Allocate more if needed */
  218|   294k|  status = ares_array_set_size(arr, arr->cnt + 1);
  219|   294k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (219:7): [True: 0, False: 294k]
  ------------------
  220|      0|    return status;
  221|      0|  }
  222|       |
  223|       |  /* Shift if we have memory but not enough room at the end */
  224|   294k|  if (arr->cnt + 1 + arr->offset > arr->alloc_cnt) {
  ------------------
  |  Branch (224:7): [True: 0, False: 294k]
  ------------------
  225|      0|    status = ares_array_move(arr, 0, arr->offset);
  226|      0|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (226:9): [True: 0, False: 0]
  ------------------
  227|      0|      return status;
  228|      0|    }
  229|      0|    arr->offset = 0;
  230|      0|  }
  231|       |
  232|       |  /* If we're inserting anywhere other than the end, we need to move some
  233|       |   * elements out of the way */
  234|   294k|  if (idx != arr->cnt) {
  ------------------
  |  Branch (234:7): [True: 0, False: 294k]
  ------------------
  235|      0|    status = ares_array_move(arr, idx + arr->offset + 1, idx + arr->offset);
  236|      0|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (236:9): [True: 0, False: 0]
  ------------------
  237|      0|      return status;
  238|      0|    }
  239|      0|  }
  240|       |
  241|       |  /* Ok, we're guaranteed to have a gap where we need it, lets zero it out,
  242|       |   * and return it */
  243|   294k|  ptr = (unsigned char *)arr->arr + ((idx + arr->offset) * arr->member_size);
  244|   294k|  memset(ptr, 0, arr->member_size);
  245|   294k|  arr->cnt++;
  246|       |
  247|   294k|  if (elem_ptr) {
  ------------------
  |  Branch (247:7): [True: 294k, False: 0]
  ------------------
  248|   294k|    *elem_ptr = ptr;
  249|   294k|  }
  250|       |
  251|   294k|  return ARES_SUCCESS;
  252|   294k|}
ares_array_insert_last:
  255|   294k|{
  256|   294k|  return ares_array_insert_at(elem_ptr, arr, ares_array_len(arr));
  257|   294k|}
ares_array_last:
  312|  25.3k|{
  313|  25.3k|  size_t cnt = ares_array_len(arr);
  314|  25.3k|  if (cnt == 0) {
  ------------------
  |  Branch (314:7): [True: 0, False: 25.3k]
  ------------------
  315|      0|    return NULL;
  316|      0|  }
  317|  25.3k|  return ares_array_at(arr, cnt - 1);
  318|  25.3k|}
ares_array_claim_at:
  336|   212k|{
  337|   212k|  ares_status_t status;
  338|       |
  339|   212k|  if (arr == NULL || idx >= arr->cnt) {
  ------------------
  |  Branch (339:7): [True: 0, False: 212k]
  |  Branch (339:22): [True: 0, False: 212k]
  ------------------
  340|      0|    return ARES_EFORMERR;
  341|      0|  }
  342|       |
  343|   212k|  if (dest != NULL && dest_size < arr->member_size) {
  ------------------
  |  Branch (343:7): [True: 0, False: 212k]
  |  Branch (343:23): [True: 0, False: 0]
  ------------------
  344|      0|    return ARES_EFORMERR;
  345|      0|  }
  346|       |
  347|   212k|  if (dest) {
  ------------------
  |  Branch (347:7): [True: 0, False: 212k]
  ------------------
  348|      0|    memcpy(dest, ares_array_at(arr, idx), arr->member_size);
  349|      0|  }
  350|       |
  351|   212k|  if (idx == 0) {
  ------------------
  |  Branch (351:7): [True: 23.8k, False: 189k]
  ------------------
  352|       |    /* Optimization, if first element, just increment offset, makes removing a
  353|       |     * lot from the start quick */
  354|  23.8k|    arr->offset++;
  355|   189k|  } else if (idx != arr->cnt - 1) {
  ------------------
  |  Branch (355:14): [True: 0, False: 189k]
  ------------------
  356|       |    /* Must shift entire array if removing an element from the middle. Does
  357|       |     * nothing if removing last element other than decrement count. */
  358|      0|    status = ares_array_move(arr, idx + arr->offset, idx + arr->offset + 1);
  359|      0|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (359:9): [True: 0, False: 0]
  ------------------
  360|      0|      return status;
  361|      0|    }
  362|      0|  }
  363|       |
  364|   212k|  arr->cnt--;
  365|   212k|  return ARES_SUCCESS;
  366|   212k|}
ares_array_remove_at:
  369|   212k|{
  370|   212k|  void *ptr = ares_array_at(arr, idx);
  371|   212k|  if (arr == NULL || ptr == NULL) {
  ------------------
  |  Branch (371:7): [True: 0, False: 212k]
  |  Branch (371:22): [True: 0, False: 212k]
  ------------------
  372|      0|    return ARES_EFORMERR;
  373|      0|  }
  374|       |
  375|   212k|  if (arr->destruct != NULL) {
  ------------------
  |  Branch (375:7): [True: 212k, False: 0]
  ------------------
  376|   212k|    arr->destruct(ptr);
  377|   212k|  }
  378|       |
  379|       |  return ares_array_claim_at(NULL, 0, arr, idx);
  380|   212k|}
ares_array_remove_last:
  388|   212k|{
  389|   212k|  size_t cnt = ares_array_len(arr);
  390|   212k|  if (cnt == 0) {
  ------------------
  |  Branch (390:7): [True: 0, False: 212k]
  ------------------
  391|      0|    return ARES_EFORMERR;
  392|      0|  }
  393|   212k|  return ares_array_remove_at(arr, cnt - 1);
  394|   212k|}

ares_llist_create:
   44|    505|{
   45|    505|  ares_llist_t *list = ares_malloc_zero(sizeof(*list));
   46|       |
   47|    505|  if (list == NULL) {
  ------------------
  |  Branch (47:7): [True: 0, False: 505]
  ------------------
   48|      0|    return NULL;
   49|      0|  }
   50|       |
   51|    505|  list->destruct = destruct;
   52|       |
   53|    505|  return list;
   54|    505|}
ares_llist_insert_last:
  150|  1.43k|{
  151|       |  return ares_llist_insert_at(list, ARES__LLIST_INSERT_TAIL, NULL, val);
  152|  1.43k|}
ares_llist_node_first:
  179|  4.09k|{
  180|  4.09k|  if (list == NULL) {
  ------------------
  |  Branch (180:7): [True: 0, False: 4.09k]
  ------------------
  181|      0|    return NULL;
  182|      0|  }
  183|  4.09k|  return list->head;
  184|  4.09k|}
ares_llist_node_next:
  215|  17.5k|{
  216|  17.5k|  if (node == NULL) {
  ------------------
  |  Branch (216:7): [True: 0, False: 17.5k]
  ------------------
  217|      0|    return NULL;
  218|      0|  }
  219|  17.5k|  return node->next;
  220|  17.5k|}
ares_llist_node_val:
  231|  17.5k|{
  232|  17.5k|  if (node == NULL) {
  ------------------
  |  Branch (232:7): [True: 0, False: 17.5k]
  ------------------
  233|      0|    return NULL;
  234|      0|  }
  235|       |
  236|  17.5k|  return node->data;
  237|  17.5k|}
ares_llist_node_claim:
  296|  1.43k|{
  297|  1.43k|  void *val;
  298|       |
  299|  1.43k|  if (node == NULL) {
  ------------------
  |  Branch (299:7): [True: 0, False: 1.43k]
  ------------------
  300|      0|    return NULL;
  301|      0|  }
  302|       |
  303|  1.43k|  val = node->data;
  304|  1.43k|  ares_llist_node_detach(node);
  305|  1.43k|  ares_free(node);
  306|       |
  307|  1.43k|  return val;
  308|  1.43k|}
ares_llist_node_destroy:
  311|  1.43k|{
  312|  1.43k|  ares_llist_destructor_t destruct;
  313|  1.43k|  void                   *val;
  314|       |
  315|  1.43k|  if (node == NULL) {
  ------------------
  |  Branch (315:7): [True: 0, False: 1.43k]
  ------------------
  316|      0|    return;
  317|      0|  }
  318|       |
  319|  1.43k|  destruct = node->parent->destruct;
  320|       |
  321|  1.43k|  val = ares_llist_node_claim(node);
  322|  1.43k|  if (val != NULL && destruct != NULL) {
  ------------------
  |  Branch (322:7): [True: 1.43k, False: 0]
  |  Branch (322:22): [True: 1.43k, False: 0]
  ------------------
  323|  1.43k|    destruct(val);
  324|  1.43k|  }
  325|  1.43k|}
ares_llist_clear:
  344|    505|{
  345|    505|  ares_llist_node_t *node;
  346|       |
  347|    505|  if (list == NULL) {
  ------------------
  |  Branch (347:7): [True: 0, False: 505]
  ------------------
  348|      0|    return;
  349|      0|  }
  350|       |
  351|  1.93k|  while ((node = ares_llist_node_first(list)) != NULL) {
  ------------------
  |  Branch (351:10): [True: 1.43k, False: 505]
  ------------------
  352|  1.43k|    ares_llist_node_destroy(node);
  353|  1.43k|  }
  354|    505|}
ares_llist_destroy:
  357|  1.82k|{
  358|  1.82k|  if (list == NULL) {
  ------------------
  |  Branch (358:7): [True: 1.31k, False: 505]
  ------------------
  359|  1.31k|    return;
  360|  1.31k|  }
  361|    505|  ares_llist_clear(list);
  362|    505|  ares_free(list);
  363|    505|}
ares_llist.c:ares_llist_insert_at:
  125|  1.43k|{
  126|  1.43k|  ares_llist_node_t *node = NULL;
  127|       |
  128|  1.43k|  if (list == NULL || val == NULL) {
  ------------------
  |  Branch (128:7): [True: 0, False: 1.43k]
  |  Branch (128:23): [True: 0, False: 1.43k]
  ------------------
  129|      0|    return NULL; /* LCOV_EXCL_LINE: DefensiveCoding */
  130|      0|  }
  131|       |
  132|  1.43k|  node = ares_malloc_zero(sizeof(*node));
  133|       |
  134|  1.43k|  if (node == NULL) {
  ------------------
  |  Branch (134:7): [True: 0, False: 1.43k]
  ------------------
  135|      0|    return NULL;
  136|      0|  }
  137|       |
  138|  1.43k|  node->data = val;
  139|  1.43k|  ares_llist_attach_at(list, type, at, node);
  140|       |
  141|  1.43k|  return node;
  142|  1.43k|}
ares_llist.c:ares_llist_node_detach:
  266|  1.43k|{
  267|  1.43k|  ares_llist_t *list;
  268|       |
  269|  1.43k|  if (node == NULL) {
  ------------------
  |  Branch (269:7): [True: 0, False: 1.43k]
  ------------------
  270|      0|    return; /* LCOV_EXCL_LINE: DefensiveCoding */
  271|      0|  }
  272|       |
  273|  1.43k|  list = node->parent;
  274|       |
  275|  1.43k|  if (node->prev) {
  ------------------
  |  Branch (275:7): [True: 0, False: 1.43k]
  ------------------
  276|      0|    node->prev->next = node->next;
  277|      0|  }
  278|       |
  279|  1.43k|  if (node->next) {
  ------------------
  |  Branch (279:7): [True: 929, False: 505]
  ------------------
  280|    929|    node->next->prev = node->prev;
  281|    929|  }
  282|       |
  283|  1.43k|  if (node == list->head) {
  ------------------
  |  Branch (283:7): [True: 1.43k, False: 0]
  ------------------
  284|  1.43k|    list->head = node->next;
  285|  1.43k|  }
  286|       |
  287|  1.43k|  if (node == list->tail) {
  ------------------
  |  Branch (287:7): [True: 505, False: 929]
  ------------------
  288|    505|    list->tail = node->prev;
  289|    505|  }
  290|       |
  291|       |  node->parent = NULL;
  292|  1.43k|  list->cnt--;
  293|  1.43k|}
ares_llist.c:ares_llist_attach_at:
   75|  1.43k|{
   76|  1.43k|  if (list == NULL || node == NULL) {
  ------------------
  |  Branch (76:7): [True: 0, False: 1.43k]
  |  Branch (76:23): [True: 0, False: 1.43k]
  ------------------
   77|      0|    return; /* LCOV_EXCL_LINE: DefensiveCoding */
   78|      0|  }
   79|       |
   80|  1.43k|  node->parent = list;
   81|       |
   82|  1.43k|  if (type == ARES__LLIST_INSERT_BEFORE && (at == list->head || at == NULL)) {
  ------------------
  |  Branch (82:7): [True: 0, False: 1.43k]
  |  Branch (82:45): [True: 0, False: 0]
  |  Branch (82:65): [True: 0, False: 0]
  ------------------
   83|      0|    type = ARES__LLIST_INSERT_HEAD;
   84|      0|  }
   85|       |
   86|  1.43k|  switch (type) {
  ------------------
  |  Branch (86:11): [True: 1.43k, False: 0]
  ------------------
   87|      0|    case ARES__LLIST_INSERT_HEAD:
  ------------------
  |  Branch (87:5): [True: 0, False: 1.43k]
  ------------------
   88|      0|      node->next = list->head;
   89|      0|      node->prev = NULL;
   90|      0|      if (list->head) {
  ------------------
  |  Branch (90:11): [True: 0, False: 0]
  ------------------
   91|      0|        list->head->prev = node;
   92|      0|      }
   93|      0|      list->head = node;
   94|      0|      break;
   95|  1.43k|    case ARES__LLIST_INSERT_TAIL:
  ------------------
  |  Branch (95:5): [True: 1.43k, False: 0]
  ------------------
   96|  1.43k|      node->next = NULL;
   97|  1.43k|      node->prev = list->tail;
   98|  1.43k|      if (list->tail) {
  ------------------
  |  Branch (98:11): [True: 929, False: 505]
  ------------------
   99|    929|        list->tail->next = node;
  100|    929|      }
  101|  1.43k|      list->tail = node;
  102|  1.43k|      break;
  103|      0|    case ARES__LLIST_INSERT_BEFORE:
  ------------------
  |  Branch (103:5): [True: 0, False: 1.43k]
  ------------------
  104|      0|      node->next = at;
  105|      0|      node->prev = at->prev;
  106|      0|      if (at->prev) {
  ------------------
  |  Branch (106:11): [True: 0, False: 0]
  ------------------
  107|      0|        at->prev->next = node;
  108|      0|      }
  109|      0|      at->prev = node;
  110|      0|      break;
  111|  1.43k|  }
  112|  1.43k|  if (list->tail == NULL) {
  ------------------
  |  Branch (112:7): [True: 0, False: 1.43k]
  ------------------
  113|      0|    list->tail = node;
  114|      0|  }
  115|  1.43k|  if (list->head == NULL) {
  ------------------
  |  Branch (115:7): [True: 505, False: 929]
  ------------------
  116|    505|    list->head = node;
  117|    505|  }
  118|       |
  119|  1.43k|  list->cnt++;
  120|  1.43k|}

ares_inet_ntop:
   66|  6.52k|{
   67|  6.52k|  switch (af) {
   68|    450|    case AF_INET:
  ------------------
  |  Branch (68:5): [True: 450, False: 6.07k]
  ------------------
   69|    450|      return inet_ntop4(src, dst, (size_t)size);
   70|  6.07k|    case AF_INET6:
  ------------------
  |  Branch (70:5): [True: 6.07k, False: 450]
  ------------------
   71|  6.07k|      return inet_ntop6(src, dst, (size_t)size);
   72|      0|    default:
  ------------------
  |  Branch (72:5): [True: 0, False: 6.52k]
  ------------------
   73|      0|      break;
   74|  6.52k|  }
   75|      0|  SET_SOCKERRNO(EAFNOSUPPORT);
  ------------------
  |  |   45|      0|#  define SET_SOCKERRNO(x) (errno = (x))
  ------------------
   76|       |  return NULL;
   77|  6.52k|}
inet_ntop.c:inet_ntop4:
   91|  1.10k|{
   92|  1.10k|  static const char fmt[] = "%u.%u.%u.%u";
   93|  1.10k|  char              tmp[sizeof("255.255.255.255")];
   94|       |
   95|  1.10k|  if (size < sizeof(tmp)) {
  ------------------
  |  Branch (95:7): [True: 0, False: 1.10k]
  ------------------
   96|      0|    SET_SOCKERRNO(ENOSPC);
  ------------------
  |  |   45|      0|#  define SET_SOCKERRNO(x) (errno = (x))
  ------------------
   97|      0|    return NULL;
   98|      0|  }
   99|       |
  100|  1.10k|  if ((size_t)snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2], src[3]) >=
  ------------------
  |  Branch (100:7): [True: 0, False: 1.10k]
  ------------------
  101|  1.10k|      size) {
  102|      0|    SET_SOCKERRNO(ENOSPC);
  ------------------
  |  |   45|      0|#  define SET_SOCKERRNO(x) (errno = (x))
  ------------------
  103|      0|    return NULL;
  104|      0|  }
  105|  1.10k|  ares_strcpy(dst, tmp, size);
  106|  1.10k|  return dst;
  107|  1.10k|}
inet_ntop.c:inet_ntop6:
  116|  6.07k|{
  117|       |  /*
  118|       |   * Note that int32_t and int16_t need only be "at least" large enough
  119|       |   * to contain a value of the specified size.  On some systems, like
  120|       |   * Crays, there is no such thing as an integer variable with 16 bits.
  121|       |   * Keep this in mind if you think this function should have been coded
  122|       |   * to use pointer overlays.  All the world's not a VAX.
  123|       |   */
  124|  6.07k|  char  tmp[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
  125|  6.07k|  char *tp;
  126|       |
  127|  6.07k|  struct {
  128|  6.07k|    ares_ssize_t base;
  129|  6.07k|    size_t       len;
  130|  6.07k|  } best, cur;
  131|       |
  132|  6.07k|  unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ];
  133|  6.07k|  size_t       i;
  134|       |
  135|       |  /*
  136|       |   * Preprocess:
  137|       |   *  Copy the input (bytewise) array into a wordwise array.
  138|       |   *  Find the longest run of 0x00's in src[] for :: shorthanding.
  139|       |   */
  140|  6.07k|  memset(words, '\0', sizeof(words));
  141|   103k|  for (i = 0; i < NS_IN6ADDRSZ; i++) {
  ------------------
  |  Branch (141:15): [True: 97.1k, False: 6.07k]
  ------------------
  142|  97.1k|    words[i / 2] |= (unsigned int)(src[i] << ((1 - (i % 2)) << 3));
  143|  97.1k|  }
  144|  6.07k|  best.base = -1;
  145|  6.07k|  best.len  = 0;
  146|  6.07k|  cur.base  = -1;
  147|  6.07k|  cur.len   = 0;
  148|  54.6k|  for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
  ------------------
  |  Branch (148:15): [True: 48.5k, False: 6.07k]
  ------------------
  149|  48.5k|    if (words[i] == 0) {
  ------------------
  |  Branch (149:9): [True: 26.1k, False: 22.4k]
  ------------------
  150|  26.1k|      if (cur.base == -1) {
  ------------------
  |  Branch (150:11): [True: 11.8k, False: 14.3k]
  ------------------
  151|  11.8k|        cur.base = (ares_ssize_t)i;
  152|  11.8k|        cur.len  = 1;
  153|  14.3k|      } else {
  154|  14.3k|        cur.len++;
  155|  14.3k|      }
  156|  26.1k|    } else {
  157|  22.4k|      if (cur.base != -1) {
  ------------------
  |  Branch (157:11): [True: 8.63k, False: 13.7k]
  ------------------
  158|  8.63k|        if (best.base == -1 || cur.len > best.len) {
  ------------------
  |  Branch (158:13): [True: 5.17k, False: 3.46k]
  |  Branch (158:32): [True: 1.44k, False: 2.01k]
  ------------------
  159|  6.61k|          best = cur;
  160|  6.61k|        }
  161|  8.63k|        cur.base = -1;
  162|  8.63k|      }
  163|  22.4k|    }
  164|  48.5k|  }
  165|  6.07k|  if (cur.base != -1) {
  ------------------
  |  Branch (165:7): [True: 3.17k, False: 2.89k]
  ------------------
  166|  3.17k|    if (best.base == -1 || cur.len > best.len) {
  ------------------
  |  Branch (166:9): [True: 611, False: 2.56k]
  |  Branch (166:28): [True: 295, False: 2.26k]
  ------------------
  167|    906|      best = cur;
  168|    906|    }
  169|  3.17k|  }
  170|  6.07k|  if (best.base != -1 && best.len < 2) {
  ------------------
  |  Branch (170:7): [True: 5.78k, False: 290]
  |  Branch (170:26): [True: 1.45k, False: 4.32k]
  ------------------
  171|  1.45k|    best.base = -1;
  172|  1.45k|  }
  173|       |
  174|       |  /*
  175|       |   * Format the result.
  176|       |   */
  177|  6.07k|  tp = tmp;
  178|  53.3k|  for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
  ------------------
  |  Branch (178:15): [True: 47.9k, False: 5.41k]
  ------------------
  179|       |    /* Are we inside the best run of 0x00's? */
  180|  47.9k|    if (best.base != -1 && i >= (size_t)best.base &&
  ------------------
  |  Branch (180:9): [True: 33.9k, False: 13.9k]
  |  Branch (180:28): [True: 27.6k, False: 6.29k]
  ------------------
  181|  27.6k|        i < ((size_t)best.base + best.len)) {
  ------------------
  |  Branch (181:9): [True: 17.5k, False: 10.1k]
  ------------------
  182|  17.5k|      if (i == (size_t)best.base) {
  ------------------
  |  Branch (182:11): [True: 4.32k, False: 13.2k]
  ------------------
  183|  4.32k|        *tp++ = ':';
  184|  4.32k|      }
  185|  17.5k|      continue;
  186|  17.5k|    }
  187|       |    /* Are we following an initial run of 0x00s or any real hex? */
  188|  30.3k|    if (i != 0) {
  ------------------
  |  Branch (188:9): [True: 26.6k, False: 3.76k]
  ------------------
  189|  26.6k|      *tp++ = ':';
  190|  26.6k|    }
  191|       |    /* Is this address an encapsulated IPv4? */
  192|  30.3k|    if (i == 6 && best.base == 0 &&
  ------------------
  |  Branch (192:9): [True: 5.24k, False: 25.1k]
  |  Branch (192:19): [True: 1.90k, False: 3.33k]
  ------------------
  193|  1.90k|        (best.len == 6 || (best.len == 7 && words[7] != 0x0001) ||
  ------------------
  |  Branch (193:10): [True: 372, False: 1.53k]
  |  Branch (193:28): [True: 0, False: 1.53k]
  |  Branch (193:45): [True: 0, False: 0]
  ------------------
  194|  1.53k|         (best.len == 5 && words[5] == 0xffff))) {
  ------------------
  |  Branch (194:11): [True: 790, False: 747]
  |  Branch (194:28): [True: 285, False: 505]
  ------------------
  195|    657|      if (!inet_ntop4(src + 12, tp, sizeof(tmp) - (size_t)(tp - tmp))) {
  ------------------
  |  Branch (195:11): [True: 0, False: 657]
  ------------------
  196|      0|        return (NULL);
  197|      0|      }
  198|    657|      tp += ares_strlen(tp);
  199|    657|      break;
  200|    657|    }
  201|  29.7k|    tp += snprintf(tp, sizeof(tmp) - (size_t)(tp - tmp), "%x", words[i]);
  202|  29.7k|  }
  203|       |  /* Was it a trailing run of 0x00's? */
  204|  6.07k|  if (best.base != -1 &&
  ------------------
  |  Branch (204:7): [True: 4.32k, False: 1.74k]
  ------------------
  205|  4.32k|      ((size_t)best.base + best.len) == (NS_IN6ADDRSZ / NS_INT16SZ)) {
  ------------------
  |  Branch (205:7): [True: 754, False: 3.57k]
  ------------------
  206|    754|    *tp++ = ':';
  207|    754|  }
  208|  6.07k|  *tp++ = '\0';
  209|       |
  210|       |  /*
  211|       |   * Check for overflow, copy, and we're done.
  212|       |   */
  213|  6.07k|  if ((size_t)(tp - tmp) > size) {
  ------------------
  |  Branch (213:7): [True: 0, False: 6.07k]
  ------------------
  214|      0|    SET_SOCKERRNO(ENOSPC);
  ------------------
  |  |   45|      0|#  define SET_SOCKERRNO(x) (errno = (x))
  ------------------
  215|      0|    return NULL;
  216|      0|  }
  217|  6.07k|  ares_strcpy(dst, tmp, size);
  218|  6.07k|  return dst;
  219|  6.07k|}

ares_dns_opcode_isvalid:
   29|  3.36k|{
   30|  3.36k|  switch (opcode) {
  ------------------
  |  Branch (30:11): [True: 3.36k, False: 2]
  ------------------
   31|  2.44k|    case ARES_OPCODE_QUERY:
  ------------------
  |  Branch (31:5): [True: 2.44k, False: 919]
  ------------------
   32|  2.61k|    case ARES_OPCODE_IQUERY:
  ------------------
  |  Branch (32:5): [True: 170, False: 3.19k]
  ------------------
   33|  2.82k|    case ARES_OPCODE_STATUS:
  ------------------
  |  Branch (33:5): [True: 212, False: 3.15k]
  ------------------
   34|  3.17k|    case ARES_OPCODE_NOTIFY:
  ------------------
  |  Branch (34:5): [True: 350, False: 3.01k]
  ------------------
   35|  3.36k|    case ARES_OPCODE_UPDATE:
  ------------------
  |  Branch (35:5): [True: 185, False: 3.17k]
  ------------------
   36|  3.36k|      return ARES_TRUE;
   37|  3.36k|  }
   38|      2|  return ARES_FALSE;
   39|  3.36k|}
ares_dns_rcode_isvalid:
   42|  5.18k|{
   43|  5.18k|  switch (rcode) {
  ------------------
  |  Branch (43:11): [True: 4.82k, False: 360]
  ------------------
   44|  3.95k|    case ARES_RCODE_NOERROR:
  ------------------
  |  Branch (44:5): [True: 3.95k, False: 1.23k]
  ------------------
   45|  4.08k|    case ARES_RCODE_FORMERR:
  ------------------
  |  Branch (45:5): [True: 135, False: 5.04k]
  ------------------
   46|  4.24k|    case ARES_RCODE_SERVFAIL:
  ------------------
  |  Branch (46:5): [True: 153, False: 5.03k]
  ------------------
   47|  4.34k|    case ARES_RCODE_NXDOMAIN:
  ------------------
  |  Branch (47:5): [True: 101, False: 5.08k]
  ------------------
   48|  4.40k|    case ARES_RCODE_NOTIMP:
  ------------------
  |  Branch (48:5): [True: 59, False: 5.12k]
  ------------------
   49|  4.47k|    case ARES_RCODE_REFUSED:
  ------------------
  |  Branch (49:5): [True: 72, False: 5.11k]
  ------------------
   50|  4.56k|    case ARES_RCODE_YXDOMAIN:
  ------------------
  |  Branch (50:5): [True: 87, False: 5.09k]
  ------------------
   51|  4.63k|    case ARES_RCODE_YXRRSET:
  ------------------
  |  Branch (51:5): [True: 69, False: 5.11k]
  ------------------
   52|  4.69k|    case ARES_RCODE_NXRRSET:
  ------------------
  |  Branch (52:5): [True: 63, False: 5.12k]
  ------------------
   53|  4.70k|    case ARES_RCODE_NOTAUTH:
  ------------------
  |  Branch (53:5): [True: 13, False: 5.17k]
  ------------------
   54|  4.73k|    case ARES_RCODE_NOTZONE:
  ------------------
  |  Branch (54:5): [True: 30, False: 5.15k]
  ------------------
   55|  4.76k|    case ARES_RCODE_DSOTYPEI:
  ------------------
  |  Branch (55:5): [True: 31, False: 5.15k]
  ------------------
   56|  4.78k|    case ARES_RCODE_BADSIG:
  ------------------
  |  Branch (56:5): [True: 20, False: 5.16k]
  ------------------
   57|  4.80k|    case ARES_RCODE_BADKEY:
  ------------------
  |  Branch (57:5): [True: 14, False: 5.17k]
  ------------------
   58|  4.80k|    case ARES_RCODE_BADTIME:
  ------------------
  |  Branch (58:5): [True: 6, False: 5.17k]
  ------------------
   59|  4.80k|    case ARES_RCODE_BADMODE:
  ------------------
  |  Branch (59:5): [True: 1, False: 5.18k]
  ------------------
   60|  4.81k|    case ARES_RCODE_BADNAME:
  ------------------
  |  Branch (60:5): [True: 3, False: 5.18k]
  ------------------
   61|  4.81k|    case ARES_RCODE_BADALG:
  ------------------
  |  Branch (61:5): [True: 2, False: 5.18k]
  ------------------
   62|  4.81k|    case ARES_RCODE_BADTRUNC:
  ------------------
  |  Branch (62:5): [True: 0, False: 5.18k]
  ------------------
   63|  4.82k|    case ARES_RCODE_BADCOOKIE:
  ------------------
  |  Branch (63:5): [True: 11, False: 5.17k]
  ------------------
   64|  4.82k|      return ARES_TRUE;
   65|  5.18k|  }
   66|    360|  return ARES_FALSE;
   67|  5.18k|}
ares_dns_flags_arevalid:
   70|  3.36k|{
   71|  3.36k|  unsigned short allflags = ARES_FLAG_QR | ARES_FLAG_AA | ARES_FLAG_TC |
   72|  3.36k|                            ARES_FLAG_RD | ARES_FLAG_RA | ARES_FLAG_AD |
   73|  3.36k|                            ARES_FLAG_CD;
   74|       |
   75|  3.36k|  if (flags & ~allflags) {
  ------------------
  |  Branch (75:7): [True: 0, False: 3.36k]
  ------------------
   76|      0|    return ARES_FALSE;
   77|      0|  }
   78|       |
   79|  3.36k|  return ARES_TRUE;
   80|  3.36k|}
ares_dns_rec_type_isvalid:
   84|   751k|{
   85|   751k|  switch (type) {
   86|  2.80k|    case ARES_REC_TYPE_A:
  ------------------
  |  Branch (86:5): [True: 2.80k, False: 749k]
  ------------------
   87|  9.32k|    case ARES_REC_TYPE_NS:
  ------------------
  |  Branch (87:5): [True: 6.51k, False: 745k]
  ------------------
   88|  15.0k|    case ARES_REC_TYPE_CNAME:
  ------------------
  |  Branch (88:5): [True: 5.75k, False: 746k]
  ------------------
   89|  35.7k|    case ARES_REC_TYPE_SOA:
  ------------------
  |  Branch (89:5): [True: 20.6k, False: 731k]
  ------------------
   90|  38.4k|    case ARES_REC_TYPE_PTR:
  ------------------
  |  Branch (90:5): [True: 2.66k, False: 749k]
  ------------------
   91|  46.9k|    case ARES_REC_TYPE_HINFO:
  ------------------
  |  Branch (91:5): [True: 8.52k, False: 743k]
  ------------------
   92|  67.1k|    case ARES_REC_TYPE_MX:
  ------------------
  |  Branch (92:5): [True: 20.2k, False: 731k]
  ------------------
   93|   430k|    case ARES_REC_TYPE_TXT:
  ------------------
  |  Branch (93:5): [True: 363k, False: 388k]
  ------------------
   94|   461k|    case ARES_REC_TYPE_SIG:
  ------------------
  |  Branch (94:5): [True: 30.8k, False: 721k]
  ------------------
   95|   488k|    case ARES_REC_TYPE_AAAA:
  ------------------
  |  Branch (95:5): [True: 27.1k, False: 724k]
  ------------------
   96|   496k|    case ARES_REC_TYPE_SRV:
  ------------------
  |  Branch (96:5): [True: 7.84k, False: 744k]
  ------------------
   97|   514k|    case ARES_REC_TYPE_NAPTR:
  ------------------
  |  Branch (97:5): [True: 17.5k, False: 734k]
  ------------------
   98|   549k|    case ARES_REC_TYPE_OPT:
  ------------------
  |  Branch (98:5): [True: 35.9k, False: 716k]
  ------------------
   99|   558k|    case ARES_REC_TYPE_TLSA:
  ------------------
  |  Branch (99:5): [True: 8.13k, False: 743k]
  ------------------
  100|   574k|    case ARES_REC_TYPE_SVCB:
  ------------------
  |  Branch (100:5): [True: 16.0k, False: 735k]
  ------------------
  101|   587k|    case ARES_REC_TYPE_HTTPS:
  ------------------
  |  Branch (101:5): [True: 13.5k, False: 738k]
  ------------------
  102|   587k|    case ARES_REC_TYPE_ANY:
  ------------------
  |  Branch (102:5): [True: 104, False: 751k]
  ------------------
  103|   594k|    case ARES_REC_TYPE_URI:
  ------------------
  |  Branch (103:5): [True: 7.15k, False: 744k]
  ------------------
  104|   601k|    case ARES_REC_TYPE_CAA:
  ------------------
  |  Branch (104:5): [True: 6.39k, False: 745k]
  ------------------
  105|   601k|      return ARES_TRUE;
  106|   111k|    case ARES_REC_TYPE_RAW_RR:
  ------------------
  |  Branch (106:5): [True: 111k, False: 640k]
  ------------------
  107|   111k|      return is_query ? ARES_FALSE : ARES_TRUE;
  ------------------
  |  Branch (107:14): [True: 0, False: 111k]
  ------------------
  108|  38.6k|    default:
  ------------------
  |  Branch (108:5): [True: 38.6k, False: 713k]
  ------------------
  109|  38.6k|      break;
  110|   751k|  }
  111|  38.6k|  return is_query ? ARES_TRUE : ARES_FALSE;
  ------------------
  |  Branch (111:10): [True: 2.36k, False: 36.3k]
  ------------------
  112|   751k|}
ares_dns_rec_allow_name_comp:
  115|  80.2k|{
  116|       |  /* Only record types defined in RFC1035 allow name compression within the
  117|       |   * RDATA.  Otherwise nameservers that don't understand an RR may not be
  118|       |   * able to pass along the RR in a proper manner */
  119|  80.2k|  switch (type) {
  120|  1.06k|    case ARES_REC_TYPE_A:
  ------------------
  |  Branch (120:5): [True: 1.06k, False: 79.2k]
  ------------------
  121|  3.54k|    case ARES_REC_TYPE_NS:
  ------------------
  |  Branch (121:5): [True: 2.48k, False: 77.7k]
  ------------------
  122|  5.66k|    case ARES_REC_TYPE_CNAME:
  ------------------
  |  Branch (122:5): [True: 2.11k, False: 78.1k]
  ------------------
  123|  7.49k|    case ARES_REC_TYPE_SOA:
  ------------------
  |  Branch (123:5): [True: 1.82k, False: 78.4k]
  ------------------
  124|  8.51k|    case ARES_REC_TYPE_PTR:
  ------------------
  |  Branch (124:5): [True: 1.02k, False: 79.2k]
  ------------------
  125|  10.6k|    case ARES_REC_TYPE_HINFO:
  ------------------
  |  Branch (125:5): [True: 2.12k, False: 78.1k]
  ------------------
  126|  14.4k|    case ARES_REC_TYPE_MX:
  ------------------
  |  Branch (126:5): [True: 3.80k, False: 76.4k]
  ------------------
  127|  16.6k|    case ARES_REC_TYPE_TXT:
  ------------------
  |  Branch (127:5): [True: 2.19k, False: 78.0k]
  ------------------
  128|  16.6k|      return ARES_TRUE;
  129|  63.6k|    default:
  ------------------
  |  Branch (129:5): [True: 63.6k, False: 16.6k]
  ------------------
  130|  63.6k|      break;
  131|  80.2k|  }
  132|  63.6k|  return ARES_FALSE;
  133|  80.2k|}
ares_dns_class_isvalid:
  138|  67.4k|{
  139|       |  /* If we don't understand the record type, we shouldn't validate the class
  140|       |   * as there are some instances like on RFC 2391 (SIG RR) the class is
  141|       |   * meaningless, but since we didn't support that record type, we didn't
  142|       |   * know it shouldn't be validated */
  143|  67.4k|  if (type == ARES_REC_TYPE_RAW_RR) {
  ------------------
  |  Branch (143:7): [True: 36.3k, False: 31.1k]
  ------------------
  144|  36.3k|    return ARES_TRUE;
  145|  36.3k|  }
  146|       |
  147|  31.1k|  switch (qclass) {
  ------------------
  |  Branch (147:11): [True: 31.0k, False: 29]
  ------------------
  148|  25.7k|    case ARES_CLASS_IN:
  ------------------
  |  Branch (148:5): [True: 25.7k, False: 5.41k]
  ------------------
  149|  26.6k|    case ARES_CLASS_CHAOS:
  ------------------
  |  Branch (149:5): [True: 943, False: 30.1k]
  ------------------
  150|  28.0k|    case ARES_CLASS_HESIOD:
  ------------------
  |  Branch (150:5): [True: 1.44k, False: 29.6k]
  ------------------
  151|  29.6k|    case ARES_CLASS_NONE:
  ------------------
  |  Branch (151:5): [True: 1.55k, False: 29.5k]
  ------------------
  152|  29.6k|      return ARES_TRUE;
  153|  1.44k|    case ARES_CLASS_ANY:
  ------------------
  |  Branch (153:5): [True: 1.44k, False: 29.6k]
  ------------------
  154|  1.44k|      if (type == ARES_REC_TYPE_SIG) {
  ------------------
  |  Branch (154:11): [True: 1.23k, False: 217]
  ------------------
  155|  1.23k|        return ARES_TRUE;
  156|  1.23k|      }
  157|    217|      if (is_query) {
  ------------------
  |  Branch (157:11): [True: 217, False: 0]
  ------------------
  158|    217|        return ARES_TRUE;
  159|    217|      }
  160|      0|      return ARES_FALSE;
  161|  31.1k|  }
  162|     29|  return ARES_FALSE;
  163|  31.1k|}
ares_dns_section_isvalid:
  166|   257k|{
  167|   257k|  switch (sect) {
  ------------------
  |  Branch (167:11): [True: 257k, False: 0]
  ------------------
  168|  66.3k|    case ARES_SECTION_ANSWER:
  ------------------
  |  Branch (168:5): [True: 66.3k, False: 190k]
  ------------------
  169|   132k|    case ARES_SECTION_AUTHORITY:
  ------------------
  |  Branch (169:5): [True: 65.9k, False: 191k]
  ------------------
  170|   257k|    case ARES_SECTION_ADDITIONAL:
  ------------------
  |  Branch (170:5): [True: 124k, False: 132k]
  ------------------
  171|   257k|      return ARES_TRUE;
  172|   257k|  }
  173|      0|  return ARES_FALSE;
  174|   257k|}
ares_dns_rr_key_to_rec_type:
  177|   620k|{
  178|       |  /* NOTE: due to the way we've numerated the keys, we can simply divide by
  179|       |   *       100 to get the type rather than having to do a huge switch
  180|       |   *       statement.  That said, we do then validate the type returned is
  181|       |   *       valid in case something completely bogus is passed in */
  182|   620k|  ares_dns_rec_type_t type = key / 100;
  183|   620k|  if (!ares_dns_rec_type_isvalid(type, ARES_FALSE)) {
  ------------------
  |  Branch (183:7): [True: 0, False: 620k]
  ------------------
  184|      0|    return 0;
  185|      0|  }
  186|   620k|  return type;
  187|   620k|}
ares_dns_rec_type_tostr:
  190|  57.7k|{
  191|  57.7k|  switch (type) {
  ------------------
  |  Branch (191:11): [True: 56.3k, False: 1.40k]
  ------------------
  192|    463|    case ARES_REC_TYPE_A:
  ------------------
  |  Branch (192:5): [True: 463, False: 57.3k]
  ------------------
  193|    463|      return "A";
  194|  1.33k|    case ARES_REC_TYPE_NS:
  ------------------
  |  Branch (194:5): [True: 1.33k, False: 56.4k]
  ------------------
  195|  1.33k|      return "NS";
  196|  1.09k|    case ARES_REC_TYPE_CNAME:
  ------------------
  |  Branch (196:5): [True: 1.09k, False: 56.6k]
  ------------------
  197|  1.09k|      return "CNAME";
  198|    871|    case ARES_REC_TYPE_SOA:
  ------------------
  |  Branch (198:5): [True: 871, False: 56.9k]
  ------------------
  199|    871|      return "SOA";
  200|    548|    case ARES_REC_TYPE_PTR:
  ------------------
  |  Branch (200:5): [True: 548, False: 57.2k]
  ------------------
  201|    548|      return "PTR";
  202|    741|    case ARES_REC_TYPE_HINFO:
  ------------------
  |  Branch (202:5): [True: 741, False: 57.0k]
  ------------------
  203|    741|      return "HINFO";
  204|  2.93k|    case ARES_REC_TYPE_MX:
  ------------------
  |  Branch (204:5): [True: 2.93k, False: 54.8k]
  ------------------
  205|  2.93k|      return "MX";
  206|  1.18k|    case ARES_REC_TYPE_TXT:
  ------------------
  |  Branch (206:5): [True: 1.18k, False: 56.6k]
  ------------------
  207|  1.18k|      return "TXT";
  208|    954|    case ARES_REC_TYPE_SIG:
  ------------------
  |  Branch (208:5): [True: 954, False: 56.8k]
  ------------------
  209|    954|      return "SIG";
  210|  6.10k|    case ARES_REC_TYPE_AAAA:
  ------------------
  |  Branch (210:5): [True: 6.10k, False: 51.6k]
  ------------------
  211|  6.10k|      return "AAAA";
  212|    595|    case ARES_REC_TYPE_SRV:
  ------------------
  |  Branch (212:5): [True: 595, False: 57.1k]
  ------------------
  213|    595|      return "SRV";
  214|    786|    case ARES_REC_TYPE_NAPTR:
  ------------------
  |  Branch (214:5): [True: 786, False: 57.0k]
  ------------------
  215|    786|      return "NAPTR";
  216|  2.64k|    case ARES_REC_TYPE_OPT:
  ------------------
  |  Branch (216:5): [True: 2.64k, False: 55.1k]
  ------------------
  217|  2.64k|      return "OPT";
  218|    623|    case ARES_REC_TYPE_TLSA:
  ------------------
  |  Branch (218:5): [True: 623, False: 57.1k]
  ------------------
  219|    623|      return "TLSA";
  220|    965|    case ARES_REC_TYPE_SVCB:
  ------------------
  |  Branch (220:5): [True: 965, False: 56.8k]
  ------------------
  221|    965|      return "SVCB";
  222|    750|    case ARES_REC_TYPE_HTTPS:
  ------------------
  |  Branch (222:5): [True: 750, False: 57.0k]
  ------------------
  223|    750|      return "HTTPS";
  224|     54|    case ARES_REC_TYPE_ANY:
  ------------------
  |  Branch (224:5): [True: 54, False: 57.7k]
  ------------------
  225|     54|      return "ANY";
  226|    564|    case ARES_REC_TYPE_URI:
  ------------------
  |  Branch (226:5): [True: 564, False: 57.2k]
  ------------------
  227|    564|      return "URI";
  228|    551|    case ARES_REC_TYPE_CAA:
  ------------------
  |  Branch (228:5): [True: 551, False: 57.2k]
  ------------------
  229|    551|      return "CAA";
  230|  32.6k|    case ARES_REC_TYPE_RAW_RR:
  ------------------
  |  Branch (230:5): [True: 32.6k, False: 25.1k]
  ------------------
  231|  32.6k|      return "RAW_RR";
  232|  57.7k|  }
  233|  1.40k|  return "UNKNOWN";
  234|  57.7k|}
ares_dns_class_tostr:
  237|  57.7k|{
  238|  57.7k|  switch (qclass) {
  ------------------
  |  Branch (238:11): [True: 27.2k, False: 30.5k]
  ------------------
  239|  22.4k|    case ARES_CLASS_IN:
  ------------------
  |  Branch (239:5): [True: 22.4k, False: 35.3k]
  ------------------
  240|  22.4k|      return "IN";
  241|  1.06k|    case ARES_CLASS_CHAOS:
  ------------------
  |  Branch (241:5): [True: 1.06k, False: 56.7k]
  ------------------
  242|  1.06k|      return "CH";
  243|  1.16k|    case ARES_CLASS_HESIOD:
  ------------------
  |  Branch (243:5): [True: 1.16k, False: 56.6k]
  ------------------
  244|  1.16k|      return "HS";
  245|  1.14k|    case ARES_CLASS_ANY:
  ------------------
  |  Branch (245:5): [True: 1.14k, False: 56.6k]
  ------------------
  246|  1.14k|      return "ANY";
  247|  1.36k|    case ARES_CLASS_NONE:
  ------------------
  |  Branch (247:5): [True: 1.36k, False: 56.4k]
  ------------------
  248|  1.36k|      return "NONE";
  249|  57.7k|  }
  250|  30.5k|  return "UNKNOWN";
  251|  57.7k|}
ares_dns_opcode_tostr:
  254|  1.82k|{
  255|  1.82k|  switch (opcode) {
  ------------------
  |  Branch (255:11): [True: 1.82k, False: 0]
  ------------------
  256|  1.25k|    case ARES_OPCODE_QUERY:
  ------------------
  |  Branch (256:5): [True: 1.25k, False: 569]
  ------------------
  257|  1.25k|      return "QUERY";
  258|     71|    case ARES_OPCODE_IQUERY:
  ------------------
  |  Branch (258:5): [True: 71, False: 1.75k]
  ------------------
  259|     71|      return "IQUERY";
  260|    114|    case ARES_OPCODE_STATUS:
  ------------------
  |  Branch (260:5): [True: 114, False: 1.70k]
  ------------------
  261|    114|      return "STATUS";
  262|    274|    case ARES_OPCODE_NOTIFY:
  ------------------
  |  Branch (262:5): [True: 274, False: 1.54k]
  ------------------
  263|    274|      return "NOTIFY";
  264|    110|    case ARES_OPCODE_UPDATE:
  ------------------
  |  Branch (264:5): [True: 110, False: 1.71k]
  ------------------
  265|    110|      return "UPDATE";
  266|  1.82k|  }
  267|      0|  return "UNKNOWN";
  268|  1.82k|}
ares_dns_rr_key_tostr:
  271|   125k|{
  272|   125k|  switch (key) {
  ------------------
  |  Branch (272:11): [True: 125k, False: 0]
  ------------------
  273|    450|    case ARES_RR_A_ADDR:
  ------------------
  |  Branch (273:5): [True: 450, False: 125k]
  ------------------
  274|    450|      return "ADDR";
  275|       |
  276|  1.28k|    case ARES_RR_NS_NSDNAME:
  ------------------
  |  Branch (276:5): [True: 1.28k, False: 124k]
  ------------------
  277|  1.28k|      return "NSDNAME";
  278|       |
  279|  1.04k|    case ARES_RR_CNAME_CNAME:
  ------------------
  |  Branch (279:5): [True: 1.04k, False: 124k]
  ------------------
  280|  1.04k|      return "CNAME";
  281|       |
  282|    862|    case ARES_RR_SOA_MNAME:
  ------------------
  |  Branch (282:5): [True: 862, False: 124k]
  ------------------
  283|    862|      return "MNAME";
  284|       |
  285|    862|    case ARES_RR_SOA_RNAME:
  ------------------
  |  Branch (285:5): [True: 862, False: 124k]
  ------------------
  286|    862|      return "RNAME";
  287|       |
  288|    862|    case ARES_RR_SOA_SERIAL:
  ------------------
  |  Branch (288:5): [True: 862, False: 124k]
  ------------------
  289|    862|      return "SERIAL";
  290|       |
  291|    862|    case ARES_RR_SOA_REFRESH:
  ------------------
  |  Branch (291:5): [True: 862, False: 124k]
  ------------------
  292|    862|      return "REFRESH";
  293|       |
  294|    862|    case ARES_RR_SOA_RETRY:
  ------------------
  |  Branch (294:5): [True: 862, False: 124k]
  ------------------
  295|    862|      return "RETRY";
  296|       |
  297|    862|    case ARES_RR_SOA_EXPIRE:
  ------------------
  |  Branch (297:5): [True: 862, False: 124k]
  ------------------
  298|    862|      return "EXPIRE";
  299|       |
  300|    862|    case ARES_RR_SOA_MINIMUM:
  ------------------
  |  Branch (300:5): [True: 862, False: 124k]
  ------------------
  301|    862|      return "MINIMUM";
  302|       |
  303|    539|    case ARES_RR_PTR_DNAME:
  ------------------
  |  Branch (303:5): [True: 539, False: 125k]
  ------------------
  304|    539|      return "DNAME";
  305|       |
  306|  6.07k|    case ARES_RR_AAAA_ADDR:
  ------------------
  |  Branch (306:5): [True: 6.07k, False: 119k]
  ------------------
  307|  6.07k|      return "ADDR";
  308|       |
  309|    727|    case ARES_RR_HINFO_CPU:
  ------------------
  |  Branch (309:5): [True: 727, False: 125k]
  ------------------
  310|    727|      return "CPU";
  311|       |
  312|    727|    case ARES_RR_HINFO_OS:
  ------------------
  |  Branch (312:5): [True: 727, False: 125k]
  ------------------
  313|    727|      return "OS";
  314|       |
  315|  2.93k|    case ARES_RR_MX_PREFERENCE:
  ------------------
  |  Branch (315:5): [True: 2.93k, False: 122k]
  ------------------
  316|  2.93k|      return "PREFERENCE";
  317|       |
  318|  2.93k|    case ARES_RR_MX_EXCHANGE:
  ------------------
  |  Branch (318:5): [True: 2.93k, False: 122k]
  ------------------
  319|  2.93k|      return "EXCHANGE";
  320|       |
  321|  1.17k|    case ARES_RR_TXT_DATA:
  ------------------
  |  Branch (321:5): [True: 1.17k, False: 124k]
  ------------------
  322|  1.17k|      return "DATA";
  323|       |
  324|    940|    case ARES_RR_SIG_TYPE_COVERED:
  ------------------
  |  Branch (324:5): [True: 940, False: 124k]
  ------------------
  325|    940|      return "TYPE_COVERED";
  326|       |
  327|    940|    case ARES_RR_SIG_ALGORITHM:
  ------------------
  |  Branch (327:5): [True: 940, False: 124k]
  ------------------
  328|    940|      return "ALGORITHM";
  329|       |
  330|    940|    case ARES_RR_SIG_LABELS:
  ------------------
  |  Branch (330:5): [True: 940, False: 124k]
  ------------------
  331|    940|      return "LABELS";
  332|       |
  333|    940|    case ARES_RR_SIG_ORIGINAL_TTL:
  ------------------
  |  Branch (333:5): [True: 940, False: 124k]
  ------------------
  334|    940|      return "ORIGINAL_TTL";
  335|       |
  336|    940|    case ARES_RR_SIG_EXPIRATION:
  ------------------
  |  Branch (336:5): [True: 940, False: 124k]
  ------------------
  337|    940|      return "EXPIRATION";
  338|       |
  339|    940|    case ARES_RR_SIG_INCEPTION:
  ------------------
  |  Branch (339:5): [True: 940, False: 124k]
  ------------------
  340|    940|      return "INCEPTION";
  341|       |
  342|    940|    case ARES_RR_SIG_KEY_TAG:
  ------------------
  |  Branch (342:5): [True: 940, False: 124k]
  ------------------
  343|    940|      return "KEY_TAG";
  344|       |
  345|    940|    case ARES_RR_SIG_SIGNERS_NAME:
  ------------------
  |  Branch (345:5): [True: 940, False: 124k]
  ------------------
  346|    940|      return "SIGNERS_NAME";
  347|       |
  348|    940|    case ARES_RR_SIG_SIGNATURE:
  ------------------
  |  Branch (348:5): [True: 940, False: 124k]
  ------------------
  349|    940|      return "SIGNATURE";
  350|       |
  351|    575|    case ARES_RR_SRV_PRIORITY:
  ------------------
  |  Branch (351:5): [True: 575, False: 125k]
  ------------------
  352|    575|      return "PRIORITY";
  353|       |
  354|    575|    case ARES_RR_SRV_WEIGHT:
  ------------------
  |  Branch (354:5): [True: 575, False: 125k]
  ------------------
  355|    575|      return "WEIGHT";
  356|       |
  357|    575|    case ARES_RR_SRV_PORT:
  ------------------
  |  Branch (357:5): [True: 575, False: 125k]
  ------------------
  358|    575|      return "PORT";
  359|       |
  360|    575|    case ARES_RR_SRV_TARGET:
  ------------------
  |  Branch (360:5): [True: 575, False: 125k]
  ------------------
  361|    575|      return "TARGET";
  362|       |
  363|    771|    case ARES_RR_NAPTR_ORDER:
  ------------------
  |  Branch (363:5): [True: 771, False: 124k]
  ------------------
  364|    771|      return "ORDER";
  365|       |
  366|    771|    case ARES_RR_NAPTR_PREFERENCE:
  ------------------
  |  Branch (366:5): [True: 771, False: 124k]
  ------------------
  367|    771|      return "PREFERENCE";
  368|       |
  369|    771|    case ARES_RR_NAPTR_FLAGS:
  ------------------
  |  Branch (369:5): [True: 771, False: 124k]
  ------------------
  370|    771|      return "FLAGS";
  371|       |
  372|    771|    case ARES_RR_NAPTR_SERVICES:
  ------------------
  |  Branch (372:5): [True: 771, False: 124k]
  ------------------
  373|    771|      return "SERVICES";
  374|       |
  375|    771|    case ARES_RR_NAPTR_REGEXP:
  ------------------
  |  Branch (375:5): [True: 771, False: 124k]
  ------------------
  376|    771|      return "REGEXP";
  377|       |
  378|    771|    case ARES_RR_NAPTR_REPLACEMENT:
  ------------------
  |  Branch (378:5): [True: 771, False: 124k]
  ------------------
  379|    771|      return "REPLACEMENT";
  380|       |
  381|  2.63k|    case ARES_RR_OPT_UDP_SIZE:
  ------------------
  |  Branch (381:5): [True: 2.63k, False: 123k]
  ------------------
  382|  2.63k|      return "UDP_SIZE";
  383|       |
  384|  2.63k|    case ARES_RR_OPT_VERSION:
  ------------------
  |  Branch (384:5): [True: 2.63k, False: 123k]
  ------------------
  385|  2.63k|      return "VERSION";
  386|       |
  387|  2.63k|    case ARES_RR_OPT_FLAGS:
  ------------------
  |  Branch (387:5): [True: 2.63k, False: 123k]
  ------------------
  388|  2.63k|      return "FLAGS";
  389|       |
  390|  2.63k|    case ARES_RR_OPT_OPTIONS:
  ------------------
  |  Branch (390:5): [True: 2.63k, False: 123k]
  ------------------
  391|  2.63k|      return "OPTIONS";
  392|       |
  393|    612|    case ARES_RR_TLSA_CERT_USAGE:
  ------------------
  |  Branch (393:5): [True: 612, False: 125k]
  ------------------
  394|    612|      return "CERT_USAGE";
  395|       |
  396|    612|    case ARES_RR_TLSA_SELECTOR:
  ------------------
  |  Branch (396:5): [True: 612, False: 125k]
  ------------------
  397|    612|      return "SELECTOR";
  398|       |
  399|    612|    case ARES_RR_TLSA_MATCH:
  ------------------
  |  Branch (399:5): [True: 612, False: 125k]
  ------------------
  400|    612|      return "MATCH";
  401|       |
  402|    612|    case ARES_RR_TLSA_DATA:
  ------------------
  |  Branch (402:5): [True: 612, False: 125k]
  ------------------
  403|    612|      return "DATA";
  404|       |
  405|    944|    case ARES_RR_SVCB_PRIORITY:
  ------------------
  |  Branch (405:5): [True: 944, False: 124k]
  ------------------
  406|    944|      return "PRIORITY";
  407|       |
  408|    944|    case ARES_RR_SVCB_TARGET:
  ------------------
  |  Branch (408:5): [True: 944, False: 124k]
  ------------------
  409|    944|      return "TARGET";
  410|       |
  411|    944|    case ARES_RR_SVCB_PARAMS:
  ------------------
  |  Branch (411:5): [True: 944, False: 124k]
  ------------------
  412|    944|      return "PARAMS";
  413|       |
  414|    735|    case ARES_RR_HTTPS_PRIORITY:
  ------------------
  |  Branch (414:5): [True: 735, False: 125k]
  ------------------
  415|    735|      return "PRIORITY";
  416|       |
  417|    735|    case ARES_RR_HTTPS_TARGET:
  ------------------
  |  Branch (417:5): [True: 735, False: 125k]
  ------------------
  418|    735|      return "TARGET";
  419|       |
  420|    735|    case ARES_RR_HTTPS_PARAMS:
  ------------------
  |  Branch (420:5): [True: 735, False: 125k]
  ------------------
  421|    735|      return "PARAMS";
  422|       |
  423|    526|    case ARES_RR_URI_PRIORITY:
  ------------------
  |  Branch (423:5): [True: 526, False: 125k]
  ------------------
  424|    526|      return "PRIORITY";
  425|       |
  426|    526|    case ARES_RR_URI_WEIGHT:
  ------------------
  |  Branch (426:5): [True: 526, False: 125k]
  ------------------
  427|    526|      return "WEIGHT";
  428|       |
  429|    526|    case ARES_RR_URI_TARGET:
  ------------------
  |  Branch (429:5): [True: 526, False: 125k]
  ------------------
  430|    526|      return "TARGET";
  431|       |
  432|    542|    case ARES_RR_CAA_CRITICAL:
  ------------------
  |  Branch (432:5): [True: 542, False: 125k]
  ------------------
  433|    542|      return "CRITICAL";
  434|       |
  435|    542|    case ARES_RR_CAA_TAG:
  ------------------
  |  Branch (435:5): [True: 542, False: 125k]
  ------------------
  436|    542|      return "TAG";
  437|       |
  438|    542|    case ARES_RR_CAA_VALUE:
  ------------------
  |  Branch (438:5): [True: 542, False: 125k]
  ------------------
  439|    542|      return "VALUE";
  440|       |
  441|  32.6k|    case ARES_RR_RAW_RR_TYPE:
  ------------------
  |  Branch (441:5): [True: 32.6k, False: 93.1k]
  ------------------
  442|  32.6k|      return "TYPE";
  443|       |
  444|  32.6k|    case ARES_RR_RAW_RR_DATA:
  ------------------
  |  Branch (444:5): [True: 32.6k, False: 93.1k]
  ------------------
  445|  32.6k|      return "DATA";
  446|   125k|  }
  447|       |
  448|      0|  return "UNKNOWN";
  449|   125k|}
ares_dns_rr_key_datatype:
  452|   814k|{
  453|   814k|  switch (key) {
  ------------------
  |  Branch (453:11): [True: 814k, False: 0]
  ------------------
  454|  1.95k|    case ARES_RR_A_ADDR:
  ------------------
  |  Branch (454:5): [True: 1.95k, False: 812k]
  ------------------
  455|  1.95k|      return ARES_DATATYPE_INADDR;
  456|       |
  457|  19.8k|    case ARES_RR_AAAA_ADDR:
  ------------------
  |  Branch (457:5): [True: 19.8k, False: 794k]
  ------------------
  458|  19.8k|      return ARES_DATATYPE_INADDR6;
  459|       |
  460|  8.79k|    case ARES_RR_NS_NSDNAME:
  ------------------
  |  Branch (460:5): [True: 8.79k, False: 805k]
  ------------------
  461|  16.1k|    case ARES_RR_CNAME_CNAME:
  ------------------
  |  Branch (461:5): [True: 7.34k, False: 806k]
  ------------------
  462|  22.3k|    case ARES_RR_SOA_MNAME:
  ------------------
  |  Branch (462:5): [True: 6.23k, False: 807k]
  ------------------
  463|  28.5k|    case ARES_RR_SOA_RNAME:
  ------------------
  |  Branch (463:5): [True: 6.13k, False: 808k]
  ------------------
  464|  32.1k|    case ARES_RR_PTR_DNAME:
  ------------------
  |  Branch (464:5): [True: 3.66k, False: 810k]
  ------------------
  465|  48.5k|    case ARES_RR_MX_EXCHANGE:
  ------------------
  |  Branch (465:5): [True: 16.3k, False: 797k]
  ------------------
  466|  55.9k|    case ARES_RR_SIG_SIGNERS_NAME:
  ------------------
  |  Branch (466:5): [True: 7.37k, False: 806k]
  ------------------
  467|  59.7k|    case ARES_RR_SRV_TARGET:
  ------------------
  |  Branch (467:5): [True: 3.83k, False: 810k]
  ------------------
  468|  66.5k|    case ARES_RR_SVCB_TARGET:
  ------------------
  |  Branch (468:5): [True: 6.73k, False: 807k]
  ------------------
  469|  72.2k|    case ARES_RR_HTTPS_TARGET:
  ------------------
  |  Branch (469:5): [True: 5.77k, False: 808k]
  ------------------
  470|  78.1k|    case ARES_RR_NAPTR_REPLACEMENT:
  ------------------
  |  Branch (470:5): [True: 5.90k, False: 808k]
  ------------------
  471|  82.2k|    case ARES_RR_URI_TARGET:
  ------------------
  |  Branch (471:5): [True: 4.06k, False: 810k]
  ------------------
  472|  82.2k|      return ARES_DATATYPE_NAME;
  473|       |
  474|  3.56k|    case ARES_RR_HINFO_CPU:
  ------------------
  |  Branch (474:5): [True: 3.56k, False: 810k]
  ------------------
  475|  7.12k|    case ARES_RR_HINFO_OS:
  ------------------
  |  Branch (475:5): [True: 3.55k, False: 810k]
  ------------------
  476|  10.4k|    case ARES_RR_NAPTR_FLAGS:
  ------------------
  |  Branch (476:5): [True: 3.34k, False: 810k]
  ------------------
  477|  13.8k|    case ARES_RR_NAPTR_SERVICES:
  ------------------
  |  Branch (477:5): [True: 3.34k, False: 810k]
  ------------------
  478|  17.1k|    case ARES_RR_NAPTR_REGEXP:
  ------------------
  |  Branch (478:5): [True: 3.34k, False: 810k]
  ------------------
  479|  19.3k|    case ARES_RR_CAA_TAG:
  ------------------
  |  Branch (479:5): [True: 2.23k, False: 811k]
  ------------------
  480|  19.3k|      return ARES_DATATYPE_STR;
  481|       |
  482|  4.14k|    case ARES_RR_SOA_SERIAL:
  ------------------
  |  Branch (482:5): [True: 4.14k, False: 810k]
  ------------------
  483|  8.28k|    case ARES_RR_SOA_REFRESH:
  ------------------
  |  Branch (483:5): [True: 4.14k, False: 810k]
  ------------------
  484|  12.4k|    case ARES_RR_SOA_RETRY:
  ------------------
  |  Branch (484:5): [True: 4.14k, False: 810k]
  ------------------
  485|  16.5k|    case ARES_RR_SOA_EXPIRE:
  ------------------
  |  Branch (485:5): [True: 4.14k, False: 810k]
  ------------------
  486|  20.7k|    case ARES_RR_SOA_MINIMUM:
  ------------------
  |  Branch (486:5): [True: 4.14k, False: 810k]
  ------------------
  487|  25.7k|    case ARES_RR_SIG_ORIGINAL_TTL:
  ------------------
  |  Branch (487:5): [True: 5.04k, False: 809k]
  ------------------
  488|  30.8k|    case ARES_RR_SIG_EXPIRATION:
  ------------------
  |  Branch (488:5): [True: 5.04k, False: 809k]
  ------------------
  489|  35.8k|    case ARES_RR_SIG_INCEPTION:
  ------------------
  |  Branch (489:5): [True: 5.04k, False: 809k]
  ------------------
  490|  35.8k|      return ARES_DATATYPE_U32;
  491|       |
  492|  10.0k|    case ARES_RR_MX_PREFERENCE:
  ------------------
  |  Branch (492:5): [True: 10.0k, False: 804k]
  ------------------
  493|  15.1k|    case ARES_RR_SIG_TYPE_COVERED:
  ------------------
  |  Branch (493:5): [True: 5.05k, False: 809k]
  ------------------
  494|  20.1k|    case ARES_RR_SIG_KEY_TAG:
  ------------------
  |  Branch (494:5): [True: 5.04k, False: 809k]
  ------------------
  495|  22.7k|    case ARES_RR_SRV_PRIORITY:
  ------------------
  |  Branch (495:5): [True: 2.62k, False: 811k]
  ------------------
  496|  25.4k|    case ARES_RR_SRV_WEIGHT:
  ------------------
  |  Branch (496:5): [True: 2.62k, False: 811k]
  ------------------
  497|  28.0k|    case ARES_RR_SRV_PORT:
  ------------------
  |  Branch (497:5): [True: 2.62k, False: 811k]
  ------------------
  498|  32.1k|    case ARES_RR_NAPTR_ORDER:
  ------------------
  |  Branch (498:5): [True: 4.10k, False: 810k]
  ------------------
  499|  36.2k|    case ARES_RR_NAPTR_PREFERENCE:
  ------------------
  |  Branch (499:5): [True: 4.10k, False: 810k]
  ------------------
  500|  48.8k|    case ARES_RR_OPT_UDP_SIZE:
  ------------------
  |  Branch (500:5): [True: 12.6k, False: 801k]
  ------------------
  501|  59.3k|    case ARES_RR_OPT_FLAGS:
  ------------------
  |  Branch (501:5): [True: 10.4k, False: 803k]
  ------------------
  502|  63.9k|    case ARES_RR_SVCB_PRIORITY:
  ------------------
  |  Branch (502:5): [True: 4.65k, False: 809k]
  ------------------
  503|  67.9k|    case ARES_RR_HTTPS_PRIORITY:
  ------------------
  |  Branch (503:5): [True: 3.97k, False: 810k]
  ------------------
  504|  70.6k|    case ARES_RR_URI_PRIORITY:
  ------------------
  |  Branch (504:5): [True: 2.73k, False: 811k]
  ------------------
  505|  73.4k|    case ARES_RR_URI_WEIGHT:
  ------------------
  |  Branch (505:5): [True: 2.73k, False: 811k]
  ------------------
  506|   178k|    case ARES_RR_RAW_RR_TYPE:
  ------------------
  |  Branch (506:5): [True: 104k, False: 709k]
  ------------------
  507|   178k|      return ARES_DATATYPE_U16;
  508|       |
  509|  5.04k|    case ARES_RR_SIG_ALGORITHM:
  ------------------
  |  Branch (509:5): [True: 5.04k, False: 809k]
  ------------------
  510|  10.0k|    case ARES_RR_SIG_LABELS:
  ------------------
  |  Branch (510:5): [True: 5.04k, False: 809k]
  ------------------
  511|  20.5k|    case ARES_RR_OPT_VERSION:
  ------------------
  |  Branch (511:5): [True: 10.4k, False: 803k]
  ------------------
  512|  23.5k|    case ARES_RR_TLSA_CERT_USAGE:
  ------------------
  |  Branch (512:5): [True: 3.04k, False: 811k]
  ------------------
  513|  26.6k|    case ARES_RR_TLSA_SELECTOR:
  ------------------
  |  Branch (513:5): [True: 3.04k, False: 811k]
  ------------------
  514|  29.6k|    case ARES_RR_TLSA_MATCH:
  ------------------
  |  Branch (514:5): [True: 3.04k, False: 811k]
  ------------------
  515|  32.4k|    case ARES_RR_CAA_CRITICAL:
  ------------------
  |  Branch (515:5): [True: 2.77k, False: 811k]
  ------------------
  516|  32.4k|      return ARES_DATATYPE_U8;
  517|       |
  518|  5.62k|    case ARES_RR_CAA_VALUE:
  ------------------
  |  Branch (518:5): [True: 5.62k, False: 808k]
  ------------------
  519|  5.62k|      return ARES_DATATYPE_BINP;
  520|       |
  521|   362k|    case ARES_RR_TXT_DATA:
  ------------------
  |  Branch (521:5): [True: 362k, False: 452k]
  ------------------
  522|   362k|      return ARES_DATATYPE_ABINP;
  523|       |
  524|  5.46k|    case ARES_RR_SIG_SIGNATURE:
  ------------------
  |  Branch (524:5): [True: 5.46k, False: 808k]
  ------------------
  525|  8.55k|    case ARES_RR_TLSA_DATA:
  ------------------
  |  Branch (525:5): [True: 3.09k, False: 811k]
  ------------------
  526|  51.1k|    case ARES_RR_RAW_RR_DATA:
  ------------------
  |  Branch (526:5): [True: 42.6k, False: 771k]
  ------------------
  527|  51.1k|      return ARES_DATATYPE_BIN;
  528|       |
  529|  9.19k|    case ARES_RR_OPT_OPTIONS:
  ------------------
  |  Branch (529:5): [True: 9.19k, False: 805k]
  ------------------
  530|  18.0k|    case ARES_RR_SVCB_PARAMS:
  ------------------
  |  Branch (530:5): [True: 8.88k, False: 805k]
  ------------------
  531|  25.1k|    case ARES_RR_HTTPS_PARAMS:
  ------------------
  |  Branch (531:5): [True: 7.09k, False: 807k]
  ------------------
  532|  25.1k|      return ARES_DATATYPE_OPT;
  533|   814k|  }
  534|       |
  535|      0|  return 0;
  536|   814k|}
ares_dns_rr_get_keys:
  590|  55.9k|{
  591|  55.9k|  if (cnt == NULL) {
  ------------------
  |  Branch (591:7): [True: 0, False: 55.9k]
  ------------------
  592|      0|    return NULL;
  593|      0|  }
  594|       |
  595|  55.9k|  *cnt = 0;
  596|       |
  597|  55.9k|  switch (type) {
  ------------------
  |  Branch (597:11): [True: 55.9k, False: 0]
  ------------------
  598|    450|    case ARES_REC_TYPE_A:
  ------------------
  |  Branch (598:5): [True: 450, False: 55.5k]
  ------------------
  599|    450|      *cnt = sizeof(rr_a_keys) / sizeof(*rr_a_keys);
  600|    450|      return rr_a_keys;
  601|  1.28k|    case ARES_REC_TYPE_NS:
  ------------------
  |  Branch (601:5): [True: 1.28k, False: 54.6k]
  ------------------
  602|  1.28k|      *cnt = sizeof(rr_ns_keys) / sizeof(*rr_ns_keys);
  603|  1.28k|      return rr_ns_keys;
  604|  1.04k|    case ARES_REC_TYPE_CNAME:
  ------------------
  |  Branch (604:5): [True: 1.04k, False: 54.9k]
  ------------------
  605|  1.04k|      *cnt = sizeof(rr_cname_keys) / sizeof(*rr_cname_keys);
  606|  1.04k|      return rr_cname_keys;
  607|    862|    case ARES_REC_TYPE_SOA:
  ------------------
  |  Branch (607:5): [True: 862, False: 55.1k]
  ------------------
  608|    862|      *cnt = sizeof(rr_soa_keys) / sizeof(*rr_soa_keys);
  609|    862|      return rr_soa_keys;
  610|    539|    case ARES_REC_TYPE_PTR:
  ------------------
  |  Branch (610:5): [True: 539, False: 55.4k]
  ------------------
  611|    539|      *cnt = sizeof(rr_ptr_keys) / sizeof(*rr_ptr_keys);
  612|    539|      return rr_ptr_keys;
  613|    727|    case ARES_REC_TYPE_HINFO:
  ------------------
  |  Branch (613:5): [True: 727, False: 55.2k]
  ------------------
  614|    727|      *cnt = sizeof(rr_hinfo_keys) / sizeof(*rr_hinfo_keys);
  615|    727|      return rr_hinfo_keys;
  616|  2.93k|    case ARES_REC_TYPE_MX:
  ------------------
  |  Branch (616:5): [True: 2.93k, False: 53.0k]
  ------------------
  617|  2.93k|      *cnt = sizeof(rr_mx_keys) / sizeof(*rr_mx_keys);
  618|  2.93k|      return rr_mx_keys;
  619|  1.17k|    case ARES_REC_TYPE_TXT:
  ------------------
  |  Branch (619:5): [True: 1.17k, False: 54.7k]
  ------------------
  620|  1.17k|      *cnt = sizeof(rr_txt_keys) / sizeof(*rr_txt_keys);
  621|  1.17k|      return rr_txt_keys;
  622|    940|    case ARES_REC_TYPE_SIG:
  ------------------
  |  Branch (622:5): [True: 940, False: 55.0k]
  ------------------
  623|    940|      *cnt = sizeof(rr_sig_keys) / sizeof(*rr_sig_keys);
  624|    940|      return rr_sig_keys;
  625|  6.07k|    case ARES_REC_TYPE_AAAA:
  ------------------
  |  Branch (625:5): [True: 6.07k, False: 49.8k]
  ------------------
  626|  6.07k|      *cnt = sizeof(rr_aaaa_keys) / sizeof(*rr_aaaa_keys);
  627|  6.07k|      return rr_aaaa_keys;
  628|    575|    case ARES_REC_TYPE_SRV:
  ------------------
  |  Branch (628:5): [True: 575, False: 55.3k]
  ------------------
  629|    575|      *cnt = sizeof(rr_srv_keys) / sizeof(*rr_srv_keys);
  630|    575|      return rr_srv_keys;
  631|    771|    case ARES_REC_TYPE_NAPTR:
  ------------------
  |  Branch (631:5): [True: 771, False: 55.1k]
  ------------------
  632|    771|      *cnt = sizeof(rr_naptr_keys) / sizeof(*rr_naptr_keys);
  633|    771|      return rr_naptr_keys;
  634|  2.63k|    case ARES_REC_TYPE_OPT:
  ------------------
  |  Branch (634:5): [True: 2.63k, False: 53.3k]
  ------------------
  635|  2.63k|      *cnt = sizeof(rr_opt_keys) / sizeof(*rr_opt_keys);
  636|  2.63k|      return rr_opt_keys;
  637|    612|    case ARES_REC_TYPE_TLSA:
  ------------------
  |  Branch (637:5): [True: 612, False: 55.3k]
  ------------------
  638|    612|      *cnt = sizeof(rr_tlsa_keys) / sizeof(*rr_tlsa_keys);
  639|    612|      return rr_tlsa_keys;
  640|    944|    case ARES_REC_TYPE_SVCB:
  ------------------
  |  Branch (640:5): [True: 944, False: 55.0k]
  ------------------
  641|    944|      *cnt = sizeof(rr_svcb_keys) / sizeof(*rr_svcb_keys);
  642|    944|      return rr_svcb_keys;
  643|    735|    case ARES_REC_TYPE_HTTPS:
  ------------------
  |  Branch (643:5): [True: 735, False: 55.2k]
  ------------------
  644|    735|      *cnt = sizeof(rr_https_keys) / sizeof(*rr_https_keys);
  645|    735|      return rr_https_keys;
  646|      0|    case ARES_REC_TYPE_ANY:
  ------------------
  |  Branch (646:5): [True: 0, False: 55.9k]
  ------------------
  647|       |      /* Not real */
  648|      0|      break;
  649|    526|    case ARES_REC_TYPE_URI:
  ------------------
  |  Branch (649:5): [True: 526, False: 55.4k]
  ------------------
  650|    526|      *cnt = sizeof(rr_uri_keys) / sizeof(*rr_uri_keys);
  651|    526|      return rr_uri_keys;
  652|    542|    case ARES_REC_TYPE_CAA:
  ------------------
  |  Branch (652:5): [True: 542, False: 55.4k]
  ------------------
  653|    542|      *cnt = sizeof(rr_caa_keys) / sizeof(*rr_caa_keys);
  654|    542|      return rr_caa_keys;
  655|  32.6k|    case ARES_REC_TYPE_RAW_RR:
  ------------------
  |  Branch (655:5): [True: 32.6k, False: 23.3k]
  ------------------
  656|  32.6k|      *cnt = sizeof(rr_raw_rr_keys) / sizeof(*rr_raw_rr_keys);
  657|  32.6k|      return rr_raw_rr_keys;
  658|  55.9k|  }
  659|       |
  660|      0|  return NULL;
  661|  55.9k|}
ares_dns_section_tostr:
  738|  5.46k|{
  739|  5.46k|  switch (section) {
  ------------------
  |  Branch (739:11): [True: 5.46k, False: 0]
  ------------------
  740|  1.82k|    case ARES_SECTION_ANSWER:
  ------------------
  |  Branch (740:5): [True: 1.82k, False: 3.64k]
  ------------------
  741|  1.82k|      return "ANSWER";
  742|  1.82k|    case ARES_SECTION_AUTHORITY:
  ------------------
  |  Branch (742:5): [True: 1.82k, False: 3.64k]
  ------------------
  743|  1.82k|      return "AUTHORITY";
  744|  1.82k|    case ARES_SECTION_ADDITIONAL:
  ------------------
  |  Branch (744:5): [True: 1.82k, False: 3.64k]
  ------------------
  745|  1.82k|      return "ADDITIONAL";
  746|  5.46k|  }
  747|      0|  return "UNKNOWN";
  748|  5.46k|}
ares_dns_rcode_tostr:
  911|  1.82k|{
  912|  1.82k|  switch (rcode) {
  ------------------
  |  Branch (912:11): [True: 1.82k, False: 0]
  ------------------
  913|    592|    case ARES_RCODE_NOERROR:
  ------------------
  |  Branch (913:5): [True: 592, False: 1.23k]
  ------------------
  914|    592|      return "NOERROR";
  915|    135|    case ARES_RCODE_FORMERR:
  ------------------
  |  Branch (915:5): [True: 135, False: 1.68k]
  ------------------
  916|    135|      return "FORMERR";
  917|    513|    case ARES_RCODE_SERVFAIL:
  ------------------
  |  Branch (917:5): [True: 513, False: 1.30k]
  ------------------
  918|    513|      return "SERVFAIL";
  919|    101|    case ARES_RCODE_NXDOMAIN:
  ------------------
  |  Branch (919:5): [True: 101, False: 1.72k]
  ------------------
  920|    101|      return "NXDOMAIN";
  921|     59|    case ARES_RCODE_NOTIMP:
  ------------------
  |  Branch (921:5): [True: 59, False: 1.76k]
  ------------------
  922|     59|      return "NOTIMP";
  923|     72|    case ARES_RCODE_REFUSED:
  ------------------
  |  Branch (923:5): [True: 72, False: 1.75k]
  ------------------
  924|     72|      return "REFUSED";
  925|     87|    case ARES_RCODE_YXDOMAIN:
  ------------------
  |  Branch (925:5): [True: 87, False: 1.73k]
  ------------------
  926|     87|      return "YXDOMAIN";
  927|     69|    case ARES_RCODE_YXRRSET:
  ------------------
  |  Branch (927:5): [True: 69, False: 1.75k]
  ------------------
  928|     69|      return "YXRRSET";
  929|     63|    case ARES_RCODE_NXRRSET:
  ------------------
  |  Branch (929:5): [True: 63, False: 1.75k]
  ------------------
  930|     63|      return "NXRRSET";
  931|     13|    case ARES_RCODE_NOTAUTH:
  ------------------
  |  Branch (931:5): [True: 13, False: 1.80k]
  ------------------
  932|     13|      return "NOTAUTH";
  933|     30|    case ARES_RCODE_NOTZONE:
  ------------------
  |  Branch (933:5): [True: 30, False: 1.79k]
  ------------------
  934|     30|      return "NOTZONE";
  935|     31|    case ARES_RCODE_DSOTYPEI:
  ------------------
  |  Branch (935:5): [True: 31, False: 1.79k]
  ------------------
  936|     31|      return "DSOTYPEI";
  937|     20|    case ARES_RCODE_BADSIG:
  ------------------
  |  Branch (937:5): [True: 20, False: 1.80k]
  ------------------
  938|     20|      return "BADSIG";
  939|     14|    case ARES_RCODE_BADKEY:
  ------------------
  |  Branch (939:5): [True: 14, False: 1.80k]
  ------------------
  940|     14|      return "BADKEY";
  941|      6|    case ARES_RCODE_BADTIME:
  ------------------
  |  Branch (941:5): [True: 6, False: 1.81k]
  ------------------
  942|      6|      return "BADTIME";
  943|      1|    case ARES_RCODE_BADMODE:
  ------------------
  |  Branch (943:5): [True: 1, False: 1.82k]
  ------------------
  944|      1|      return "BADMODE";
  945|      3|    case ARES_RCODE_BADNAME:
  ------------------
  |  Branch (945:5): [True: 3, False: 1.81k]
  ------------------
  946|      3|      return "BADNAME";
  947|      2|    case ARES_RCODE_BADALG:
  ------------------
  |  Branch (947:5): [True: 2, False: 1.82k]
  ------------------
  948|      2|      return "BADALG";
  949|      0|    case ARES_RCODE_BADTRUNC:
  ------------------
  |  Branch (949:5): [True: 0, False: 1.82k]
  ------------------
  950|      0|      return "BADTRUNC";
  951|     11|    case ARES_RCODE_BADCOOKIE:
  ------------------
  |  Branch (951:5): [True: 11, False: 1.81k]
  ------------------
  952|     11|      return "BADCOOKIE";
  953|  1.82k|  }
  954|       |
  955|      0|  return "UNKNOWN";
  956|  1.82k|}

ares_dns_multistring_create:
   55|  1.21k|{
   56|  1.21k|  ares_dns_multistring_t *strs = ares_malloc_zero(sizeof(*strs));
   57|  1.21k|  if (strs == NULL) {
  ------------------
  |  Branch (57:7): [True: 0, False: 1.21k]
  ------------------
   58|      0|    return NULL;
   59|      0|  }
   60|       |
   61|  1.21k|  strs->strs =
   62|  1.21k|    ares_array_create(sizeof(multistring_data_t), ares_dns_multistring_free_cb);
   63|  1.21k|  if (strs->strs == NULL) {
  ------------------
  |  Branch (63:7): [True: 0, False: 1.21k]
  ------------------
   64|      0|    ares_free(strs);
   65|      0|    return NULL;
   66|      0|  }
   67|       |
   68|  1.21k|  return strs;
   69|  1.21k|}
ares_dns_multistring_clear:
   72|  1.21k|{
   73|  1.21k|  if (strs == NULL) {
  ------------------
  |  Branch (73:7): [True: 0, False: 1.21k]
  ------------------
   74|      0|    return;
   75|      0|  }
   76|       |
   77|   191k|  while (ares_array_len(strs->strs)) {
  ------------------
  |  Branch (77:10): [True: 190k, False: 1.21k]
  ------------------
   78|   190k|    ares_array_remove_last(strs->strs);
   79|   190k|  }
   80|  1.21k|}
ares_dns_multistring_destroy:
   83|  1.22k|{
   84|  1.22k|  if (strs == NULL) {
  ------------------
  |  Branch (84:7): [True: 14, False: 1.21k]
  ------------------
   85|     14|    return;
   86|     14|  }
   87|  1.21k|  ares_dns_multistring_clear(strs);
   88|  1.21k|  ares_array_destroy(strs->strs);
   89|  1.21k|  ares_free(strs->cache_str);
   90|  1.21k|  ares_free(strs);
   91|  1.21k|}
ares_dns_multistring_add_own:
  129|   190k|{
  130|   190k|  multistring_data_t *data;
  131|   190k|  ares_status_t       status;
  132|       |
  133|   190k|  if (strs == NULL) {
  ------------------
  |  Branch (133:7): [True: 0, False: 190k]
  ------------------
  134|      0|    return ARES_EFORMERR;
  135|      0|  }
  136|       |
  137|   190k|  strs->cache_invalidated = ARES_TRUE;
  138|       |
  139|       |  /* NOTE: its ok to have an empty string added */
  140|   190k|  if (str == NULL && len != 0) {
  ------------------
  |  Branch (140:7): [True: 182k, False: 8.22k]
  |  Branch (140:22): [True: 0, False: 182k]
  ------------------
  141|      0|    return ARES_EFORMERR;
  142|      0|  }
  143|       |
  144|   190k|  status = ares_array_insert_last((void **)&data, strs->strs);
  145|   190k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (145:7): [True: 0, False: 190k]
  ------------------
  146|      0|    return status;
  147|      0|  }
  148|       |
  149|       |  /* Issue #921, ares_dns_multistring_get() doesn't have a way to indicate
  150|       |   * success or fail on a zero-length string which is actually valid.  So we
  151|       |   * are going to allocate a 1-byte buffer to use as a placeholder in this
  152|       |   * case */
  153|   190k|  if (str == NULL) {
  ------------------
  |  Branch (153:7): [True: 182k, False: 8.22k]
  ------------------
  154|   182k|    str = ares_malloc_zero(1);
  155|   182k|    if (str == NULL) {
  ------------------
  |  Branch (155:9): [True: 0, False: 182k]
  ------------------
  156|      0|      ares_array_remove_last(strs->strs);
  157|      0|      return ARES_ENOMEM;
  158|      0|    }
  159|   182k|  }
  160|       |
  161|   190k|  data->data = str;
  162|   190k|  data->len  = len;
  163|       |
  164|   190k|  return ARES_SUCCESS;
  165|   190k|}
ares_dns_multistring_cnt:
  168|   139k|{
  169|   139k|  if (strs == NULL) {
  ------------------
  |  Branch (169:7): [True: 0, False: 139k]
  ------------------
  170|      0|    return 0;
  171|      0|  }
  172|   139k|  return ares_array_len(strs->strs);
  173|   139k|}
ares_dns_multistring_get:
  178|   220k|{
  179|   220k|  const multistring_data_t *data;
  180|       |
  181|   220k|  if (strs == NULL || len == NULL) {
  ------------------
  |  Branch (181:7): [True: 0, False: 220k]
  |  Branch (181:23): [True: 0, False: 220k]
  ------------------
  182|      0|    return NULL;
  183|      0|  }
  184|       |
  185|   220k|  data = ares_array_at_const(strs->strs, idx);
  186|   220k|  if (data == NULL) {
  ------------------
  |  Branch (186:7): [True: 0, False: 220k]
  ------------------
  187|      0|    return NULL;
  188|      0|  }
  189|       |
  190|   220k|  *len = data->len;
  191|   220k|  return data->data;
  192|   220k|}
ares_dns_multistring_parse_buf:
  243|  1.21k|{
  244|  1.21k|  unsigned char len;
  245|  1.21k|  ares_status_t status   = ARES_EBADRESP;
  246|  1.21k|  size_t        orig_len = ares_buf_len(buf);
  247|       |
  248|  1.21k|  if (buf == NULL) {
  ------------------
  |  Branch (248:7): [True: 0, False: 1.21k]
  ------------------
  249|      0|    return ARES_EFORMERR;
  250|      0|  }
  251|       |
  252|  1.21k|  if (remaining_len == 0) {
  ------------------
  |  Branch (252:7): [True: 1, False: 1.21k]
  ------------------
  253|      1|    return ARES_EBADRESP;
  254|      1|  }
  255|       |
  256|  1.21k|  if (strs != NULL) {
  ------------------
  |  Branch (256:7): [True: 1.21k, False: 0]
  ------------------
  257|  1.21k|    *strs = ares_dns_multistring_create();
  258|  1.21k|    if (*strs == NULL) {
  ------------------
  |  Branch (258:9): [True: 0, False: 1.21k]
  ------------------
  259|      0|      return ARES_ENOMEM;
  260|      0|    }
  261|  1.21k|  }
  262|       |
  263|   191k|  while (orig_len - ares_buf_len(buf) < remaining_len) {
  ------------------
  |  Branch (263:10): [True: 190k, False: 1.20k]
  ------------------
  264|   190k|    status = ares_buf_fetch_bytes(buf, &len, 1);
  265|   190k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (265:9): [True: 0, False: 190k]
  ------------------
  266|      0|      break; /* LCOV_EXCL_LINE: DefensiveCoding */
  267|      0|    }
  268|       |
  269|       |
  270|       |    /* When used by the _str() parser, it really needs to be validated to
  271|       |     * be a valid printable ascii string.  Do that here */
  272|   190k|    if (len && validate_printable && ares_buf_len(buf) >= len) {
  ------------------
  |  Branch (272:9): [True: 8.23k, False: 182k]
  |  Branch (272:16): [True: 0, False: 8.23k]
  |  Branch (272:38): [True: 0, False: 0]
  ------------------
  273|      0|      size_t      mylen;
  274|      0|      const char *data = (const char *)ares_buf_peek(buf, &mylen);
  275|      0|      if (!ares_str_isprint(data, len)) {
  ------------------
  |  Branch (275:11): [True: 0, False: 0]
  ------------------
  276|      0|        status = ARES_EBADSTR;
  277|      0|        break;
  278|      0|      }
  279|      0|    }
  280|       |
  281|   190k|    if (strs != NULL) {
  ------------------
  |  Branch (281:9): [True: 190k, False: 0]
  ------------------
  282|   190k|      unsigned char *data = NULL;
  283|   190k|      if (len) {
  ------------------
  |  Branch (283:11): [True: 8.23k, False: 182k]
  ------------------
  284|  8.23k|        status = ares_buf_fetch_bytes_dup(buf, len, ARES_TRUE, &data);
  285|  8.23k|        if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (285:13): [True: 13, False: 8.22k]
  ------------------
  286|     13|          break;
  287|     13|        }
  288|  8.23k|      }
  289|   190k|      status = ares_dns_multistring_add_own(*strs, data, len);
  290|   190k|      if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (290:11): [True: 0, False: 190k]
  ------------------
  291|      0|        ares_free(data);
  292|      0|        break;
  293|      0|      }
  294|   190k|    } else {
  295|      0|      status = ares_buf_consume(buf, len);
  296|      0|      if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (296:11): [True: 0, False: 0]
  ------------------
  297|      0|        break;
  298|      0|      }
  299|      0|    }
  300|       |
  301|   190k|  }
  302|       |
  303|  1.21k|  if (status != ARES_SUCCESS && strs != NULL) {
  ------------------
  |  Branch (303:7): [True: 13, False: 1.20k]
  |  Branch (303:33): [True: 13, False: 0]
  ------------------
  304|     13|    ares_dns_multistring_destroy(*strs);
  305|     13|    *strs = NULL;
  306|     13|  }
  307|       |
  308|  1.21k|  return status;
  309|  1.21k|}
ares_dns_multistring.c:ares_dns_multistring_free_cb:
   46|   190k|{
   47|   190k|  multistring_data_t *data = arg;
   48|   190k|  if (data == NULL) {
  ------------------
  |  Branch (48:7): [True: 0, False: 190k]
  ------------------
   49|      0|    return;
   50|      0|  }
   51|   190k|  ares_free(data->data);
   52|   190k|}

ares_dns_name_write:
  358|  25.7k|{
  359|  25.7k|  const ares_nameoffset_t *off = NULL;
  360|  25.7k|  size_t                   name_len;
  361|  25.7k|  size_t                   orig_name_len;
  362|  25.7k|  size_t                   pos    = ares_buf_len(buf);
  363|  25.7k|  ares_array_t            *labels = NULL;
  364|  25.7k|  char                     name_copy[512];
  365|  25.7k|  ares_status_t            status;
  366|       |
  367|  25.7k|  if (buf == NULL || name == NULL) {
  ------------------
  |  Branch (367:7): [True: 0, False: 25.7k]
  |  Branch (367:22): [True: 0, False: 25.7k]
  ------------------
  368|      0|    return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
  369|      0|  }
  370|       |
  371|  25.7k|  labels = ares_array_create(sizeof(ares_buf_t *), ares_dns_labels_free_cb);
  372|  25.7k|  if (labels == NULL) {
  ------------------
  |  Branch (372:7): [True: 0, False: 25.7k]
  ------------------
  373|      0|    return ARES_ENOMEM;
  374|      0|  }
  375|       |
  376|       |  /* NOTE: due to possible escaping, name_copy buffer is > 256 to allow for
  377|       |   *       this */
  378|  25.7k|  name_len      = ares_strcpy(name_copy, name, sizeof(name_copy));
  379|  25.7k|  orig_name_len = name_len;
  380|       |
  381|       |  /* Find longest match */
  382|  25.7k|  if (list != NULL) {
  ------------------
  |  Branch (382:7): [True: 22.1k, False: 3.59k]
  ------------------
  383|  22.1k|    off = ares_nameoffset_find(*list, name_copy);
  384|  22.1k|    if (off != NULL && off->name_len != name_len) {
  ------------------
  |  Branch (384:9): [True: 1.42k, False: 20.7k]
  |  Branch (384:24): [True: 396, False: 1.03k]
  ------------------
  385|       |      /* truncate */
  386|    396|      name_len            -= (off->name_len + 1);
  387|    396|      name_copy[name_len]  = 0;
  388|    396|    }
  389|  22.1k|  }
  390|       |
  391|       |  /* Output labels */
  392|  25.7k|  if (off == NULL || off->name_len != orig_name_len) {
  ------------------
  |  Branch (392:7): [True: 24.3k, False: 1.42k]
  |  Branch (392:22): [True: 396, False: 1.03k]
  ------------------
  393|  24.6k|    size_t i;
  394|       |
  395|  24.6k|    status = ares_split_dns_name(labels, validate_hostname, name_copy);
  396|  24.6k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (396:9): [True: 379, False: 24.3k]
  ------------------
  397|    379|      goto done;
  398|    379|    }
  399|       |
  400|  31.9k|    for (i = 0; i < ares_array_len(labels); i++) {
  ------------------
  |  Branch (400:17): [True: 7.65k, False: 24.3k]
  ------------------
  401|  7.65k|      size_t               len  = 0;
  402|  7.65k|      const ares_buf_t    *lbuf = ares_dns_labels_get_at(labels, i);
  403|  7.65k|      const unsigned char *ptr  = ares_buf_peek(lbuf, &len);
  404|       |
  405|  7.65k|      status = ares_buf_append_byte(buf, (unsigned char)(len & 0xFF));
  406|  7.65k|      if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (406:11): [True: 0, False: 7.65k]
  ------------------
  407|      0|        goto done; /* LCOV_EXCL_LINE: OutOfMemory */
  408|      0|      }
  409|       |
  410|  7.65k|      status = ares_buf_append(buf, ptr, len);
  411|  7.65k|      if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (411:11): [True: 0, False: 7.65k]
  ------------------
  412|      0|        goto done; /* LCOV_EXCL_LINE: OutOfMemory */
  413|      0|      }
  414|  7.65k|    }
  415|       |
  416|       |    /* If we are NOT jumping to another label, output terminator */
  417|  24.3k|    if (off == NULL) {
  ------------------
  |  Branch (417:9): [True: 23.9k, False: 382]
  ------------------
  418|  23.9k|      status = ares_buf_append_byte(buf, 0);
  419|  23.9k|      if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (419:11): [True: 0, False: 23.9k]
  ------------------
  420|      0|        goto done; /* LCOV_EXCL_LINE: OutOfMemory */
  421|      0|      }
  422|  23.9k|    }
  423|  24.3k|  }
  424|       |
  425|       |  /* Output name compression offset jump */
  426|  25.3k|  if (off != NULL) {
  ------------------
  |  Branch (426:7): [True: 1.41k, False: 23.9k]
  ------------------
  427|  1.41k|    unsigned short u16 =
  428|  1.41k|      (unsigned short)0xC000 | (unsigned short)(off->idx & 0x3FFF);
  429|  1.41k|    status = ares_buf_append_be16(buf, u16);
  430|  1.41k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (430:9): [True: 0, False: 1.41k]
  ------------------
  431|      0|      goto done; /* LCOV_EXCL_LINE: OutOfMemory */
  432|      0|    }
  433|  1.41k|  }
  434|       |
  435|       |  /* Store pointer for future jumps as long as its not an exact match for
  436|       |   * a prior entry */
  437|  25.3k|  if (list != NULL && (off == NULL || off->name_len != orig_name_len) &&
  ------------------
  |  Branch (437:7): [True: 21.7k, False: 3.59k]
  |  Branch (437:24): [True: 20.3k, False: 1.41k]
  |  Branch (437:39): [True: 382, False: 1.03k]
  ------------------
  438|  20.7k|      name_len > 0) {
  ------------------
  |  Branch (438:7): [True: 1.47k, False: 19.2k]
  ------------------
  439|  1.47k|    status = ares_nameoffset_create(list, name /* not truncated copy! */, pos);
  440|  1.47k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (440:9): [True: 45, False: 1.43k]
  ------------------
  441|     45|      goto done; /* LCOV_EXCL_LINE: OutOfMemory */
  442|     45|    }
  443|  1.47k|  }
  444|       |
  445|  25.3k|  status = ARES_SUCCESS;
  446|       |
  447|  25.7k|done:
  448|  25.7k|  ares_array_destroy(labels);
  449|  25.7k|  return status;
  450|  25.3k|}
ares_dns_name_parse:
  540|  81.6k|{
  541|  81.6k|  size_t        save_offset = 0;
  542|  81.6k|  unsigned char c;
  543|  81.6k|  ares_status_t status;
  544|  81.6k|  ares_buf_t   *namebuf     = NULL;
  545|  81.6k|  size_t        label_start = ares_buf_get_position(buf);
  546|       |
  547|  81.6k|  if (buf == NULL) {
  ------------------
  |  Branch (547:7): [True: 0, False: 81.6k]
  ------------------
  548|      0|    return ARES_EFORMERR;
  549|      0|  }
  550|       |
  551|  81.6k|  if (name != NULL) {
  ------------------
  |  Branch (551:7): [True: 81.6k, False: 0]
  ------------------
  552|  81.6k|    namebuf = ares_buf_create();
  553|  81.6k|    if (namebuf == NULL) {
  ------------------
  |  Branch (553:9): [True: 0, False: 81.6k]
  ------------------
  554|      0|      status = ARES_ENOMEM;
  555|      0|      goto fail;
  556|      0|    }
  557|  81.6k|  }
  558|       |
  559|       |  /* The compression scheme allows a domain name in a message to be
  560|       |   * represented as either:
  561|       |   *
  562|       |   * - a sequence of labels ending in a zero octet
  563|       |   * - a pointer
  564|       |   * - a sequence of labels ending with a pointer
  565|       |   */
  566|  3.79M|  while (1) {
  ------------------
  |  Branch (566:10): [True: 3.79M, Folded]
  ------------------
  567|       |    /* Keep track of the minimum label starting position to prevent forward
  568|       |     * jumping */
  569|  3.79M|    if (label_start > ares_buf_get_position(buf)) {
  ------------------
  |  Branch (569:9): [True: 15.9k, False: 3.78M]
  ------------------
  570|  15.9k|      label_start = ares_buf_get_position(buf);
  571|  15.9k|    }
  572|       |
  573|  3.79M|    status = ares_buf_fetch_bytes(buf, &c, 1);
  574|  3.79M|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (574:9): [True: 89, False: 3.79M]
  ------------------
  575|     89|      goto fail;
  576|     89|    }
  577|       |
  578|       |    /* Pointer/Redirect */
  579|  3.79M|    if ((c & 0xc0) == 0xc0) {
  ------------------
  |  Branch (579:9): [True: 15.9k, False: 3.78M]
  ------------------
  580|       |      /* The pointer takes the form of a two octet sequence:
  581|       |       *
  582|       |       *   +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  583|       |       *   | 1  1|                OFFSET                   |
  584|       |       *   +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  585|       |       *
  586|       |       * The first two bits are ones.  This allows a pointer to be distinguished
  587|       |       * from a label, since the label must begin with two zero bits because
  588|       |       * labels are restricted to 63 octets or less.  (The 10 and 01
  589|       |       * combinations are reserved for future use.)  The OFFSET field specifies
  590|       |       * an offset from the start of the message (i.e., the first octet of the
  591|       |       * ID field in the domain header).  A zero offset specifies the first byte
  592|       |       * of the ID field, etc.
  593|       |       */
  594|  15.9k|      size_t offset = (size_t)((c & 0x3F) << 8);
  595|       |
  596|       |      /* Fetch second byte of the redirect length */
  597|  15.9k|      status = ares_buf_fetch_bytes(buf, &c, 1);
  598|  15.9k|      if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (598:11): [True: 2, False: 15.9k]
  ------------------
  599|      2|        goto fail;
  600|      2|      }
  601|       |
  602|  15.9k|      offset |= ((size_t)c);
  603|       |
  604|       |      /* According to RFC 1035 4.1.4:
  605|       |       *    In this scheme, an entire domain name or a list of labels at
  606|       |       *    the end of a domain name is replaced with a pointer to a prior
  607|       |       *    occurrence of the same name.
  608|       |       * Note the word "prior", meaning it must go backwards.  This was
  609|       |       * confirmed via the ISC BIND code that it also prevents forward
  610|       |       * pointers.
  611|       |       */
  612|  15.9k|      if (offset >= label_start) {
  ------------------
  |  Branch (612:11): [True: 59, False: 15.9k]
  ------------------
  613|     59|        status = ARES_EBADNAME;
  614|     59|        goto fail;
  615|     59|      }
  616|       |
  617|       |      /* First time we make a jump, save the current position */
  618|  15.9k|      if (save_offset == 0) {
  ------------------
  |  Branch (618:11): [True: 10.3k, False: 5.57k]
  ------------------
  619|  10.3k|        save_offset = ares_buf_get_position(buf);
  620|  10.3k|      }
  621|       |
  622|  15.9k|      status = ares_buf_set_position(buf, offset);
  623|  15.9k|      if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (623:11): [True: 0, False: 15.9k]
  ------------------
  624|      0|        status = ARES_EBADNAME;
  625|      0|        goto fail;
  626|      0|      }
  627|       |
  628|  15.9k|      continue;
  629|  3.78M|    } else if ((c & 0xc0) != 0) {
  ------------------
  |  Branch (629:16): [True: 12, False: 3.78M]
  ------------------
  630|       |      /* 10 and 01 are reserved */
  631|     12|      status = ARES_EBADNAME;
  632|     12|      goto fail;
  633|  3.78M|    } else if (c == 0) {
  ------------------
  |  Branch (633:16): [True: 81.4k, False: 3.70M]
  ------------------
  634|       |      /* termination via zero octet*/
  635|  81.4k|      break;
  636|  81.4k|    }
  637|       |
  638|       |    /* New label */
  639|       |
  640|       |    /* Labels are separated by periods */
  641|  3.70M|    if (ares_buf_len(namebuf) != 0 && name != NULL) {
  ------------------
  |  Branch (641:9): [True: 3.68M, False: 10.6k]
  |  Branch (641:39): [True: 3.68M, False: 0]
  ------------------
  642|  3.68M|      status = ares_buf_append_byte(namebuf, '.');
  643|  3.68M|      if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (643:11): [True: 0, False: 3.68M]
  ------------------
  644|      0|        goto fail; /* LCOV_EXCL_LINE: OutOfMemory */
  645|      0|      }
  646|  3.68M|    }
  647|       |
  648|  3.70M|    status = ares_fetch_dnsname_into_buf(buf, namebuf, c, is_hostname);
  649|  3.70M|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (649:9): [True: 27, False: 3.70M]
  ------------------
  650|     27|      goto fail;
  651|     27|    }
  652|  3.70M|  }
  653|       |
  654|       |  /* Restore offset read after first redirect/pointer as this is where the DNS
  655|       |   * message continues */
  656|  81.4k|  if (save_offset) {
  ------------------
  |  Branch (656:7): [True: 10.3k, False: 71.1k]
  ------------------
  657|  10.3k|    ares_buf_set_position(buf, save_offset);
  658|  10.3k|  }
  659|       |
  660|  81.4k|  if (name != NULL) {
  ------------------
  |  Branch (660:7): [True: 81.4k, False: 0]
  ------------------
  661|  81.4k|    *name = ares_buf_finish_str(namebuf, NULL);
  662|  81.4k|    if (*name == NULL) {
  ------------------
  |  Branch (662:9): [True: 0, False: 81.4k]
  ------------------
  663|      0|      status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
  664|      0|      goto fail;            /* LCOV_EXCL_LINE: OutOfMemory */
  665|      0|    }
  666|  81.4k|  }
  667|       |
  668|  81.4k|  return ARES_SUCCESS;
  669|       |
  670|    189|fail:
  671|       |  /* We want badname response if we couldn't parse */
  672|    189|  if (status == ARES_EBADRESP) {
  ------------------
  |  Branch (672:7): [True: 118, False: 71]
  ------------------
  673|    118|    status = ARES_EBADNAME;
  674|    118|  }
  675|       |
  676|    189|  ares_buf_destroy(namebuf);
  677|    189|  return status;
  678|  81.4k|}
ares_dns_name.c:ares_dns_labels_free_cb:
  140|  31.4k|{
  141|  31.4k|  ares_buf_t **buf = arg;
  142|  31.4k|  if (buf == NULL) {
  ------------------
  |  Branch (142:7): [True: 0, False: 31.4k]
  ------------------
  143|      0|    return;
  144|      0|  }
  145|       |
  146|  31.4k|  ares_buf_destroy(*buf);
  147|  31.4k|}
ares_dns_name.c:ares_nameoffset_find:
   93|  22.1k|{
   94|  22.1k|  size_t                   name_len = ares_strlen(name);
   95|  22.1k|  ares_llist_node_t       *node;
   96|  22.1k|  const ares_nameoffset_t *longest_match = NULL;
   97|       |
   98|  22.1k|  if (list == NULL || name == NULL || name_len == 0) {
  ------------------
  |  Branch (98:7): [True: 17.5k, False: 4.56k]
  |  Branch (98:23): [True: 0, False: 4.56k]
  |  Branch (98:39): [True: 2.40k, False: 2.16k]
  ------------------
   99|  19.9k|    return NULL;
  100|  19.9k|  }
  101|       |
  102|  19.7k|  for (node = ares_llist_node_first(list); node != NULL;
  ------------------
  |  Branch (102:44): [True: 17.5k, False: 2.16k]
  ------------------
  103|  17.5k|       node = ares_llist_node_next(node)) {
  104|  17.5k|    const ares_nameoffset_t *val = ares_llist_node_val(node);
  105|  17.5k|    size_t                   prefix_len;
  106|       |
  107|       |    /* Can't be a match if the stored name is longer */
  108|  17.5k|    if (val->name_len > name_len) {
  ------------------
  |  Branch (108:9): [True: 7.70k, False: 9.88k]
  ------------------
  109|  7.70k|      continue;
  110|  7.70k|    }
  111|       |
  112|       |    /* Can't be the longest match if our existing longest match is longer */
  113|  9.88k|    if (longest_match != NULL && longest_match->name_len > val->name_len) {
  ------------------
  |  Branch (113:9): [True: 6.22k, False: 3.65k]
  |  Branch (113:34): [True: 3.27k, False: 2.94k]
  ------------------
  114|  3.27k|      continue;
  115|  3.27k|    }
  116|       |
  117|  6.60k|    prefix_len = name_len - val->name_len;
  118|       |
  119|       |    /* Due to DNS 0x20, lets not inadvertently mangle things, use case-sensitive
  120|       |     * matching instead of case-insensitive.  This may result in slightly
  121|       |     * larger DNS queries overall. */
  122|  6.60k|    if (!ares_streq(val->name, name + prefix_len)) {
  ------------------
  |  Branch (122:9): [True: 4.12k, False: 2.47k]
  ------------------
  123|  4.12k|      continue;
  124|  4.12k|    }
  125|       |
  126|       |    /* We need to make sure if `val->name` is "example.com" that name is
  127|       |     * is separated by a label, e.g. "myexample.com" is not ok, however
  128|       |     * "my.example.com" is, so we look for the preceding "." */
  129|  2.47k|    if (prefix_len != 0 && name[prefix_len - 1] != '.') {
  ------------------
  |  Branch (129:9): [True: 1.44k, False: 1.03k]
  |  Branch (129:28): [True: 363, False: 1.08k]
  ------------------
  130|    363|      continue;
  131|    363|    }
  132|       |
  133|  2.11k|    longest_match = val;
  134|  2.11k|  }
  135|       |
  136|  2.16k|  return longest_match;
  137|  22.1k|}
ares_dns_name.c:ares_split_dns_name:
  252|  24.6k|{
  253|  24.6k|  ares_status_t status;
  254|  24.6k|  ares_buf_t   *label   = NULL;
  255|  24.6k|  ares_buf_t   *namebuf = NULL;
  256|  24.6k|  size_t        i;
  257|  24.6k|  size_t        total_len = 0;
  258|  24.6k|  unsigned char c;
  259|       |
  260|  24.6k|  if (name == NULL || labels == NULL) {
  ------------------
  |  Branch (260:7): [True: 0, False: 24.6k]
  |  Branch (260:23): [True: 0, False: 24.6k]
  ------------------
  261|      0|    return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
  262|      0|  }
  263|       |
  264|       |  /* Put name into a buffer for parsing */
  265|  24.6k|  namebuf = ares_buf_create();
  266|  24.6k|  if (namebuf == NULL) {
  ------------------
  |  Branch (266:7): [True: 0, False: 24.6k]
  ------------------
  267|      0|    status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
  268|      0|    goto done;            /* LCOV_EXCL_LINE: OutOfMemory */
  269|      0|  }
  270|       |
  271|  24.6k|  if (*name != '\0') {
  ------------------
  |  Branch (271:7): [True: 2.06k, False: 22.6k]
  ------------------
  272|  2.06k|    status =
  273|  2.06k|      ares_buf_append(namebuf, (const unsigned char *)name, ares_strlen(name));
  274|  2.06k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (274:9): [True: 0, False: 2.06k]
  ------------------
  275|      0|      goto done; /* LCOV_EXCL_LINE: OutOfMemory */
  276|      0|    }
  277|  2.06k|  }
  278|       |
  279|       |  /* Start with 1 label */
  280|  24.6k|  label = ares_dns_labels_add(labels);
  281|  24.6k|  if (label == NULL) {
  ------------------
  |  Branch (281:7): [True: 0, False: 24.6k]
  ------------------
  282|      0|    status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
  283|      0|    goto done;            /* LCOV_EXCL_LINE: OutOfMemory */
  284|      0|  }
  285|       |
  286|  95.5k|  while (ares_buf_fetch_bytes(namebuf, &c, 1) == ARES_SUCCESS) {
  ------------------
  |  Branch (286:10): [True: 71.2k, False: 24.3k]
  ------------------
  287|       |    /* New label */
  288|  71.2k|    if (c == '.') {
  ------------------
  |  Branch (288:9): [True: 6.78k, False: 64.4k]
  ------------------
  289|  6.78k|      label = ares_dns_labels_add(labels);
  290|  6.78k|      if (label == NULL) {
  ------------------
  |  Branch (290:11): [True: 0, False: 6.78k]
  ------------------
  291|      0|        status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
  292|      0|        goto done;            /* LCOV_EXCL_LINE: OutOfMemory */
  293|      0|      }
  294|  6.78k|      continue;
  295|  6.78k|    }
  296|       |
  297|       |    /* Escape */
  298|  64.4k|    if (c == '\\') {
  ------------------
  |  Branch (298:9): [True: 40.5k, False: 23.9k]
  ------------------
  299|  40.5k|      status = ares_parse_dns_name_escape(namebuf, label, validate_hostname);
  300|  40.5k|      if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (300:11): [True: 321, False: 40.1k]
  ------------------
  301|    321|        goto done;
  302|    321|      }
  303|  40.1k|      continue;
  304|  40.5k|    }
  305|       |
  306|       |    /* Output direct character */
  307|  23.9k|    if (validate_hostname && !ares_is_hostnamech(c)) {
  ------------------
  |  |  131|  7.77k|  (ares_isalpha(x) || ares_isdigit(x) || ((unsigned char)(x)) == '-' || \
  |  |  ------------------
  |  |  |  |  106|  15.5k|#define ares_isalpha(x) (ares_islower(x) || ares_isupper(x))
  |  |  |  |  ------------------
  |  |  |  |  |  |  104|  15.5k|#define ares_islower(x) (((unsigned char)x) >= 'a' && ((unsigned char)x) <= 'z')
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (104:26): [True: 1.69k, False: 6.07k]
  |  |  |  |  |  |  |  Branch (104:55): [True: 1.69k, False: 5]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define ares_isalpha(x) (ares_islower(x) || ares_isupper(x))
  |  |  |  |  ------------------
  |  |  |  |  |  |  102|  6.07k|#define ares_isupper(x) (((unsigned char)x) >= 'A' && ((unsigned char)x) <= 'Z')
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (102:26): [True: 2.92k, False: 3.15k]
  |  |  |  |  |  |  |  Branch (102:55): [True: 2.24k, False: 687]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 (ares_isalpha(x) || ares_isdigit(x) || ((unsigned char)(x)) == '-' || \
  |  |  ------------------
  |  |  |  |   95|  11.6k|#define ares_isdigit(x) (((unsigned char)x) >= '0' && ((unsigned char)x) <= '9')
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (95:26): [True: 2.15k, False: 1.68k]
  |  |  |  |  |  Branch (95:55): [True: 1.45k, False: 700]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (131:42): [True: 741, False: 1.64k]
  |  |  ------------------
  |  |  132|  7.77k|   ((unsigned char)(x)) == '.' || ((unsigned char)(x)) == '_' ||        \
  |  |  ------------------
  |  |  |  Branch (132:4): [True: 0, False: 1.64k]
  |  |  |  Branch (132:35): [True: 673, False: 972]
  |  |  ------------------
  |  |  133|  7.77k|   ((unsigned char)(x)) == '/' || ((unsigned char)(x)) == '*')
  |  |  ------------------
  |  |  |  Branch (133:4): [True: 337, False: 635]
  |  |  |  Branch (133:35): [True: 589, False: 46]
  |  |  ------------------
  ------------------
  |  Branch (307:9): [True: 7.77k, False: 16.1k]
  ------------------
  308|     46|      status = ARES_EBADNAME;
  309|     46|      goto done;
  310|     46|    }
  311|       |
  312|  23.9k|    status = ares_buf_append_byte(label, c);
  313|  23.9k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (313:9): [True: 0, False: 23.9k]
  ------------------
  314|      0|      goto done; /* LCOV_EXCL_LINE: OutOfMemory */
  315|      0|    }
  316|  23.9k|  }
  317|       |
  318|       |  /* Remove trailing blank label */
  319|  24.3k|  if (ares_buf_len(ares_dns_labels_get_last(labels)) == 0) {
  ------------------
  |  Branch (319:7): [True: 22.6k, False: 1.68k]
  ------------------
  320|  22.6k|    ares_dns_name_labels_del_last(labels);
  321|  22.6k|  }
  322|       |
  323|       |  /* If someone passed in "." there could have been 2 blank labels, check for
  324|       |   * that */
  325|  24.3k|  if (ares_array_len(labels) == 1 &&
  ------------------
  |  Branch (325:7): [True: 993, False: 23.3k]
  ------------------
  326|    993|      ares_buf_len(ares_dns_labels_get_last(labels)) == 0) {
  ------------------
  |  Branch (326:7): [True: 0, False: 993]
  ------------------
  327|      0|    ares_dns_name_labels_del_last(labels);
  328|      0|  }
  329|       |
  330|       |  /* Scan to make sure label lengths are valid */
  331|  32.5k|  for (i = 0; i < ares_array_len(labels); i++) {
  ------------------
  |  Branch (331:15): [True: 8.22k, False: 24.3k]
  ------------------
  332|  8.22k|    const ares_buf_t *buf = ares_dns_labels_get_at(labels, i);
  333|  8.22k|    size_t            len = ares_buf_len(buf);
  334|       |    /* No 0-length labels, and no labels over 63 bytes */
  335|  8.22k|    if (len == 0 || len > 63) {
  ------------------
  |  Branch (335:9): [True: 0, False: 8.22k]
  |  Branch (335:21): [True: 0, False: 8.22k]
  ------------------
  336|      0|      status = ARES_EBADNAME;
  337|      0|      goto done;
  338|      0|    }
  339|  8.22k|    total_len += len;
  340|  8.22k|  }
  341|       |
  342|       |  /* Can't exceed maximum (unescaped) length */
  343|  24.3k|  if (ares_array_len(labels) && total_len + ares_array_len(labels) - 1 > 255) {
  ------------------
  |  Branch (343:7): [True: 1.69k, False: 22.6k]
  |  Branch (343:33): [True: 12, False: 1.68k]
  ------------------
  344|     12|    status = ARES_EBADNAME;
  345|     12|    goto done;
  346|     12|  }
  347|       |
  348|  24.3k|  status = ARES_SUCCESS;
  349|       |
  350|  24.6k|done:
  351|  24.6k|  ares_buf_destroy(namebuf);
  352|  24.6k|  return status;
  353|  24.3k|}
ares_dns_name.c:ares_dns_labels_add:
  150|  31.4k|{
  151|  31.4k|  ares_buf_t **buf;
  152|       |
  153|  31.4k|  if (labels == NULL) {
  ------------------
  |  Branch (153:7): [True: 0, False: 31.4k]
  ------------------
  154|      0|    return NULL; /* LCOV_EXCL_LINE: DefensiveCoding */
  155|      0|  }
  156|       |
  157|  31.4k|  if (ares_array_insert_last((void **)&buf, labels) != ARES_SUCCESS) {
  ------------------
  |  Branch (157:7): [True: 0, False: 31.4k]
  ------------------
  158|      0|    return NULL;
  159|      0|  }
  160|       |
  161|  31.4k|  *buf = ares_buf_create();
  162|  31.4k|  if (*buf == NULL) {
  ------------------
  |  Branch (162:7): [True: 0, False: 31.4k]
  ------------------
  163|      0|    ares_array_remove_last(labels);
  164|      0|    return NULL;
  165|      0|  }
  166|       |
  167|  31.4k|  return *buf;
  168|  31.4k|}
ares_dns_name.c:ares_parse_dns_name_escape:
  200|  40.5k|{
  201|  40.5k|  ares_status_t status;
  202|  40.5k|  unsigned char c;
  203|       |
  204|  40.5k|  status = ares_buf_fetch_bytes(namebuf, &c, 1);
  205|  40.5k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (205:7): [True: 10, False: 40.4k]
  ------------------
  206|     10|    return ARES_EBADNAME;
  207|     10|  }
  208|       |
  209|       |  /* If next character is a digit, read 2 more digits */
  210|  40.4k|  if (ares_isdigit(c)) {
  ------------------
  |  |   95|  40.4k|#define ares_isdigit(x) (((unsigned char)x) >= '0' && ((unsigned char)x) <= '9')
  |  |  ------------------
  |  |  |  Branch (95:26): [True: 31.5k, False: 8.91k]
  |  |  |  Branch (95:55): [True: 30.2k, False: 1.32k]
  |  |  ------------------
  ------------------
  211|  30.2k|    size_t       i;
  212|  30.2k|    unsigned int val = 0;
  213|       |
  214|  30.2k|    val = c - '0';
  215|       |
  216|  90.7k|    for (i = 0; i < 2; i++) {
  ------------------
  |  Branch (216:17): [True: 60.5k, False: 30.2k]
  ------------------
  217|  60.5k|      status = ares_buf_fetch_bytes(namebuf, &c, 1);
  218|  60.5k|      if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (218:11): [True: 10, False: 60.4k]
  ------------------
  219|     10|        return ARES_EBADNAME;
  220|     10|      }
  221|       |
  222|  60.4k|      if (!ares_isdigit(c)) {
  ------------------
  |  |   95|  60.4k|#define ares_isdigit(x) (((unsigned char)x) >= '0' && ((unsigned char)x) <= '9')
  |  |  ------------------
  |  |  |  Branch (95:26): [True: 60.4k, False: 0]
  |  |  |  Branch (95:55): [True: 60.4k, False: 0]
  |  |  ------------------
  ------------------
  223|      0|        return ARES_EBADNAME;
  224|      0|      }
  225|  60.4k|      val *= 10;
  226|  60.4k|      val += c - '0';
  227|  60.4k|    }
  228|       |
  229|       |    /* Out of range */
  230|  30.2k|    if (val > 255) {
  ------------------
  |  Branch (230:9): [True: 0, False: 30.2k]
  ------------------
  231|      0|      return ARES_EBADNAME;
  232|      0|    }
  233|       |
  234|  30.2k|    if (validate_hostname && !ares_is_hostnamech((unsigned char)val)) {
  ------------------
  |  |  131|    278|  (ares_isalpha(x) || ares_isdigit(x) || ((unsigned char)(x)) == '-' || \
  |  |  ------------------
  |  |  |  |  106|    556|#define ares_isalpha(x) (ares_islower(x) || ares_isupper(x))
  |  |  |  |  ------------------
  |  |  |  |  |  |  104|    556|#define ares_islower(x) (((unsigned char)x) >= 'a' && ((unsigned char)x) <= 'z')
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (104:26): [True: 81, False: 197]
  |  |  |  |  |  |  |  Branch (104:55): [True: 0, False: 81]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define ares_isalpha(x) (ares_islower(x) || ares_isupper(x))
  |  |  |  |  ------------------
  |  |  |  |  |  |  102|    278|#define ares_isupper(x) (((unsigned char)x) >= 'A' && ((unsigned char)x) <= 'Z')
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (102:26): [True: 81, False: 197]
  |  |  |  |  |  |  |  Branch (102:55): [True: 0, False: 81]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 (ares_isalpha(x) || ares_isdigit(x) || ((unsigned char)(x)) == '-' || \
  |  |  ------------------
  |  |  |  |   95|    556|#define ares_isdigit(x) (((unsigned char)x) >= '0' && ((unsigned char)x) <= '9')
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (95:26): [True: 81, False: 197]
  |  |  |  |  |  Branch (95:55): [True: 0, False: 81]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (131:42): [True: 0, False: 278]
  |  |  ------------------
  |  |  132|    278|   ((unsigned char)(x)) == '.' || ((unsigned char)(x)) == '_' ||        \
  |  |  ------------------
  |  |  |  Branch (132:4): [True: 0, False: 278]
  |  |  |  Branch (132:35): [True: 0, False: 278]
  |  |  ------------------
  |  |  133|    278|   ((unsigned char)(x)) == '/' || ((unsigned char)(x)) == '*')
  |  |  ------------------
  |  |  |  Branch (133:4): [True: 0, False: 278]
  |  |  |  Branch (133:35): [True: 0, False: 278]
  |  |  ------------------
  ------------------
  |  Branch (234:9): [True: 278, False: 29.9k]
  ------------------
  235|    278|      return ARES_EBADNAME;
  236|    278|    }
  237|       |
  238|  29.9k|    return ares_buf_append_byte(label, (unsigned char)val);
  239|  30.2k|  }
  240|       |
  241|       |  /* We can just output the character */
  242|  10.2k|  if (validate_hostname && !ares_is_hostnamech(c)) {
  ------------------
  |  |  131|    767|  (ares_isalpha(x) || ares_isdigit(x) || ((unsigned char)(x)) == '-' || \
  |  |  ------------------
  |  |  |  |  106|  1.53k|#define ares_isalpha(x) (ares_islower(x) || ares_isupper(x))
  |  |  |  |  ------------------
  |  |  |  |  |  |  104|  1.53k|#define ares_islower(x) (((unsigned char)x) >= 'a' && ((unsigned char)x) <= 'z')
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (104:26): [True: 0, False: 767]
  |  |  |  |  |  |  |  Branch (104:55): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define ares_isalpha(x) (ares_islower(x) || ares_isupper(x))
  |  |  |  |  ------------------
  |  |  |  |  |  |  102|    767|#define ares_isupper(x) (((unsigned char)x) >= 'A' && ((unsigned char)x) <= 'Z')
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (102:26): [True: 4, False: 763]
  |  |  |  |  |  |  |  Branch (102:55): [True: 0, False: 4]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 (ares_isalpha(x) || ares_isdigit(x) || ((unsigned char)(x)) == '-' || \
  |  |  ------------------
  |  |  |  |   95|  1.53k|#define ares_isdigit(x) (((unsigned char)x) >= '0' && ((unsigned char)x) <= '9')
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (95:26): [True: 8, False: 759]
  |  |  |  |  |  Branch (95:55): [True: 0, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (131:42): [True: 0, False: 767]
  |  |  ------------------
  |  |  132|    767|   ((unsigned char)(x)) == '.' || ((unsigned char)(x)) == '_' ||        \
  |  |  ------------------
  |  |  |  Branch (132:4): [True: 744, False: 23]
  |  |  |  Branch (132:35): [True: 0, False: 23]
  |  |  ------------------
  |  |  133|    767|   ((unsigned char)(x)) == '/' || ((unsigned char)(x)) == '*')
  |  |  ------------------
  |  |  |  Branch (133:4): [True: 0, False: 23]
  |  |  |  Branch (133:35): [True: 0, False: 23]
  |  |  ------------------
  ------------------
  |  Branch (242:7): [True: 767, False: 9.47k]
  ------------------
  243|     23|    return ARES_EBADNAME;
  244|     23|  }
  245|       |
  246|  10.2k|  return ares_buf_append_byte(label, c);
  247|  10.2k|}
ares_dns_name.c:ares_dns_labels_get_last:
  171|  25.3k|{
  172|  25.3k|  ares_buf_t **buf = ares_array_last(labels);
  173|       |
  174|  25.3k|  if (buf == NULL) {
  ------------------
  |  Branch (174:7): [True: 0, False: 25.3k]
  ------------------
  175|      0|    return NULL;
  176|      0|  }
  177|       |
  178|  25.3k|  return *buf;
  179|  25.3k|}
ares_dns_name.c:ares_dns_name_labels_del_last:
  193|  22.6k|{
  194|  22.6k|  ares_array_remove_last(labels);
  195|  22.6k|}
ares_dns_name.c:ares_dns_labels_get_at:
  182|  15.8k|{
  183|  15.8k|  ares_buf_t **buf = ares_array_at(labels, idx);
  184|       |
  185|  15.8k|  if (buf == NULL) {
  ------------------
  |  Branch (185:7): [True: 0, False: 15.8k]
  ------------------
  186|      0|    return NULL;
  187|      0|  }
  188|       |
  189|  15.8k|  return *buf;
  190|  15.8k|}
ares_dns_name.c:ares_nameoffset_create:
   46|  1.47k|{
   47|  1.47k|  ares_status_t      status;
   48|  1.47k|  ares_nameoffset_t *off = NULL;
   49|       |
   50|  1.47k|  if (list == NULL || name == NULL || ares_strlen(name) == 0 ||
  ------------------
  |  Branch (50:7): [True: 0, False: 1.47k]
  |  Branch (50:23): [True: 0, False: 1.47k]
  |  Branch (50:39): [True: 0, False: 1.47k]
  ------------------
   51|  1.47k|      ares_strlen(name) > 255) {
  ------------------
  |  Branch (51:7): [True: 45, False: 1.43k]
  ------------------
   52|     45|    return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
   53|     45|  }
   54|       |
   55|  1.43k|  if (*list == NULL) {
  ------------------
  |  Branch (55:7): [True: 505, False: 929]
  ------------------
   56|    505|    *list = ares_llist_create(ares_nameoffset_free);
   57|    505|  }
   58|  1.43k|  if (*list == NULL) {
  ------------------
  |  Branch (58:7): [True: 0, False: 1.43k]
  ------------------
   59|      0|    status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
   60|      0|    goto fail;            /* LCOV_EXCL_LINE: OutOfMemory */
   61|      0|  }
   62|       |
   63|  1.43k|  off = ares_malloc_zero(sizeof(*off));
   64|  1.43k|  if (off == NULL) {
  ------------------
  |  Branch (64:7): [True: 0, False: 1.43k]
  ------------------
   65|      0|    return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
   66|      0|  }
   67|       |
   68|  1.43k|  off->name = ares_strdup(name);
   69|  1.43k|  if (off->name == NULL) {
  ------------------
  |  Branch (69:7): [True: 0, False: 1.43k]
  ------------------
   70|      0|    status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
   71|      0|    goto fail;            /* LCOV_EXCL_LINE: OutOfMemory */
   72|      0|  }
   73|       |
   74|  1.43k|  off->name_len = ares_strlen(off->name);
   75|  1.43k|  off->idx      = idx;
   76|       |
   77|  1.43k|  if (ares_llist_insert_last(*list, off) == NULL) {
  ------------------
  |  Branch (77:7): [True: 0, False: 1.43k]
  ------------------
   78|      0|    status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
   79|      0|    goto fail;            /* LCOV_EXCL_LINE: OutOfMemory */
   80|      0|  }
   81|       |
   82|  1.43k|  return ARES_SUCCESS;
   83|       |
   84|       |/* LCOV_EXCL_START: OutOfMemory */
   85|      0|fail:
   86|      0|  ares_nameoffset_free(off);
   87|      0|  return status;
   88|       |  /* LCOV_EXCL_STOP */
   89|  1.43k|}
ares_dns_name.c:ares_nameoffset_free:
   35|  1.43k|{
   36|  1.43k|  ares_nameoffset_t *off = arg;
   37|  1.43k|  if (off == NULL) {
  ------------------
  |  Branch (37:7): [True: 0, False: 1.43k]
  ------------------
   38|      0|    return; /* LCOV_EXCL_LINE: DefensiveCoding */
   39|      0|  }
   40|  1.43k|  ares_free(off->name);
   41|  1.43k|  ares_free(off);
   42|  1.43k|}
ares_dns_name.c:ares_fetch_dnsname_into_buf:
  475|  3.70M|{
  476|  3.70M|  size_t               remaining_len;
  477|  3.70M|  const unsigned char *ptr = ares_buf_peek(buf, &remaining_len);
  478|  3.70M|  ares_status_t        status;
  479|  3.70M|  size_t               i;
  480|       |
  481|  3.70M|  if (buf == NULL || len == 0 || remaining_len < len) {
  ------------------
  |  Branch (481:7): [True: 0, False: 3.70M]
  |  Branch (481:22): [True: 0, False: 3.70M]
  |  Branch (481:34): [True: 27, False: 3.70M]
  ------------------
  482|     27|    return ARES_EBADRESP;
  483|     27|  }
  484|       |
  485|  76.7M|  for (i = 0; i < len; i++) {
  ------------------
  |  Branch (485:15): [True: 73.0M, False: 3.70M]
  ------------------
  486|  73.0M|    unsigned char c = ptr[i];
  487|       |
  488|       |    /* Hostnames have a very specific allowed character set.  Anything outside
  489|       |     * of that (non-printable and reserved included) are disallowed */
  490|  73.0M|    if (is_hostname && !ares_is_hostnamech(c)) {
  ------------------
  |  |  131|      0|  (ares_isalpha(x) || ares_isdigit(x) || ((unsigned char)(x)) == '-' || \
  |  |  ------------------
  |  |  |  |  106|      0|#define ares_isalpha(x) (ares_islower(x) || ares_isupper(x))
  |  |  |  |  ------------------
  |  |  |  |  |  |  104|      0|#define ares_islower(x) (((unsigned char)x) >= 'a' && ((unsigned char)x) <= 'z')
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (104:26): [True: 0, False: 0]
  |  |  |  |  |  |  |  Branch (104:55): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define ares_isalpha(x) (ares_islower(x) || ares_isupper(x))
  |  |  |  |  ------------------
  |  |  |  |  |  |  102|      0|#define ares_isupper(x) (((unsigned char)x) >= 'A' && ((unsigned char)x) <= 'Z')
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (102:26): [True: 0, False: 0]
  |  |  |  |  |  |  |  Branch (102:55): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 (ares_isalpha(x) || ares_isdigit(x) || ((unsigned char)(x)) == '-' || \
  |  |  ------------------
  |  |  |  |   95|      0|#define ares_isdigit(x) (((unsigned char)x) >= '0' && ((unsigned char)x) <= '9')
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (95:26): [True: 0, False: 0]
  |  |  |  |  |  Branch (95:55): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (131:42): [True: 0, False: 0]
  |  |  ------------------
  |  |  132|      0|   ((unsigned char)(x)) == '.' || ((unsigned char)(x)) == '_' ||        \
  |  |  ------------------
  |  |  |  Branch (132:4): [True: 0, False: 0]
  |  |  |  Branch (132:35): [True: 0, False: 0]
  |  |  ------------------
  |  |  133|      0|   ((unsigned char)(x)) == '/' || ((unsigned char)(x)) == '*')
  |  |  ------------------
  |  |  |  Branch (133:4): [True: 0, False: 0]
  |  |  |  Branch (133:35): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (490:9): [True: 0, False: 73.0M]
  ------------------
  491|      0|      status = ARES_EBADRESP;
  492|      0|      goto fail;
  493|      0|    }
  494|       |
  495|       |    /* NOTE: dest may be NULL if the user is trying to skip the name. validation
  496|       |     *       still occurs above. */
  497|  73.0M|    if (dest == NULL) {
  ------------------
  |  Branch (497:9): [True: 0, False: 73.0M]
  ------------------
  498|      0|      continue;
  499|      0|    }
  500|       |
  501|       |    /* Non-printable characters need to be output as \DDD */
  502|  73.0M|    if (!ares_isprint(c)) {
  ------------------
  |  |  114|  73.0M|  (((unsigned char)(x)) >= 0x20 && ((unsigned char)(x)) <= 0x7E)
  |  |  ------------------
  |  |  |  Branch (114:4): [True: 727k, False: 72.3M]
  |  |  |  Branch (114:36): [True: 575k, False: 151k]
  |  |  ------------------
  ------------------
  503|  72.4M|      unsigned char escape[4];
  504|       |
  505|  72.4M|      escape[0] = '\\';
  506|  72.4M|      escape[1] = '0' + (c / 100);
  507|  72.4M|      escape[2] = '0' + ((c % 100) / 10);
  508|  72.4M|      escape[3] = '0' + (c % 10);
  509|       |
  510|  72.4M|      status = ares_buf_append(dest, escape, sizeof(escape));
  511|  72.4M|      if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (511:11): [True: 0, False: 72.4M]
  ------------------
  512|      0|        goto fail; /* LCOV_EXCL_LINE: OutOfMemory */
  513|      0|      }
  514|       |
  515|  72.4M|      continue;
  516|  72.4M|    }
  517|       |
  518|       |    /* Reserved characters need to be escaped, otherwise normal */
  519|   575k|    if (is_reservedch(c)) {
  ------------------
  |  Branch (519:9): [True: 84.5k, False: 490k]
  ------------------
  520|  84.5k|      status = ares_buf_append_byte(dest, '\\');
  521|  84.5k|      if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (521:11): [True: 0, False: 84.5k]
  ------------------
  522|      0|        goto fail; /* LCOV_EXCL_LINE: OutOfMemory */
  523|      0|      }
  524|  84.5k|    }
  525|       |
  526|   575k|    status = ares_buf_append_byte(dest, c);
  527|   575k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (527:9): [True: 0, False: 575k]
  ------------------
  528|      0|      return status; /* LCOV_EXCL_LINE: OutOfMemory */
  529|      0|    }
  530|   575k|  }
  531|       |
  532|  3.70M|  return ares_buf_consume(buf, len);
  533|       |
  534|      0|fail:
  535|      0|  return status;
  536|  3.70M|}
ares_dns_name.c:is_reservedch:
  454|   575k|{
  455|   575k|  switch (ch) {
  456|  1.13k|    case '"':
  ------------------
  |  Branch (456:5): [True: 1.13k, False: 574k]
  ------------------
  457|  17.0k|    case '.':
  ------------------
  |  Branch (457:5): [True: 15.8k, False: 559k]
  ------------------
  458|  38.3k|    case ';':
  ------------------
  |  Branch (458:5): [True: 21.2k, False: 553k]
  ------------------
  459|  43.4k|    case '\\':
  ------------------
  |  Branch (459:5): [True: 5.17k, False: 570k]
  ------------------
  460|  56.2k|    case '(':
  ------------------
  |  Branch (460:5): [True: 12.7k, False: 562k]
  ------------------
  461|  57.5k|    case ')':
  ------------------
  |  Branch (461:5): [True: 1.34k, False: 573k]
  ------------------
  462|  78.6k|    case '@':
  ------------------
  |  Branch (462:5): [True: 21.0k, False: 554k]
  ------------------
  463|  84.5k|    case '$':
  ------------------
  |  Branch (463:5): [True: 5.87k, False: 569k]
  ------------------
  464|  84.5k|      return ARES_TRUE;
  465|   490k|    default:
  ------------------
  |  Branch (465:5): [True: 490k, False: 84.5k]
  ------------------
  466|   490k|      break;
  467|   575k|  }
  468|       |
  469|   490k|  return ARES_FALSE;
  470|   575k|}

ares_dns_parse:
 1321|  3.39k|{
 1322|  3.39k|  ares_buf_t   *parser = NULL;
 1323|  3.39k|  ares_status_t status;
 1324|       |
 1325|  3.39k|  if (buf == NULL || buf_len == 0 || dnsrec == NULL) {
  ------------------
  |  Branch (1325:7): [True: 0, False: 3.39k]
  |  Branch (1325:22): [True: 0, False: 3.39k]
  |  Branch (1325:38): [True: 0, False: 3.39k]
  ------------------
 1326|      0|    return ARES_EFORMERR;
 1327|      0|  }
 1328|       |
 1329|  3.39k|  parser = ares_buf_create_const(buf, buf_len);
 1330|  3.39k|  if (parser == NULL) {
  ------------------
  |  Branch (1330:7): [True: 0, False: 3.39k]
  ------------------
 1331|      0|    return ARES_ENOMEM;
 1332|      0|  }
 1333|       |
 1334|  3.39k|  status = ares_dns_parse_buf(parser, flags, dnsrec);
 1335|  3.39k|  ares_buf_destroy(parser);
 1336|       |
 1337|  3.39k|  return status;
 1338|  3.39k|}
ares_dns_parse.c:ares_dns_parse_buf:
 1187|  3.39k|{
 1188|  3.39k|  ares_status_t  status;
 1189|  3.39k|  size_t         total_rr_count;
 1190|  3.39k|  const size_t   min_rr_wire_len = 11;
 1191|  3.39k|  unsigned short qdcount;
 1192|  3.39k|  unsigned short ancount;
 1193|  3.39k|  unsigned short nscount;
 1194|  3.39k|  unsigned short arcount;
 1195|  3.39k|  unsigned short i;
 1196|       |
 1197|  3.39k|  if (buf == NULL || dnsrec == NULL) {
  ------------------
  |  Branch (1197:7): [True: 0, False: 3.39k]
  |  Branch (1197:22): [True: 0, False: 3.39k]
  ------------------
 1198|      0|    return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
 1199|      0|  }
 1200|       |
 1201|       |  /* Maximum DNS packet size is 64k, even over TCP */
 1202|  3.39k|  if (ares_buf_len(buf) > 0xFFFF) {
  ------------------
  |  Branch (1202:7): [True: 0, False: 3.39k]
  ------------------
 1203|      0|    return ARES_EFORMERR;
 1204|      0|  }
 1205|       |
 1206|       |  /* All communications inside of the domain protocol are carried in a single
 1207|       |   * format called a message.  The top level format of message is divided
 1208|       |   * into 5 sections (some of which are empty in certain cases) shown below:
 1209|       |   *
 1210|       |   * +---------------------+
 1211|       |   * |        Header       |
 1212|       |   * +---------------------+
 1213|       |   * |       Question      | the question for the name server
 1214|       |   * +---------------------+
 1215|       |   * |        Answer       | RRs answering the question
 1216|       |   * +---------------------+
 1217|       |   * |      Authority      | RRs pointing toward an authority
 1218|       |   * +---------------------+
 1219|       |   * |      Additional     | RRs holding additional information
 1220|       |   * +---------------------+
 1221|       |   */
 1222|       |
 1223|       |  /* Parse header */
 1224|  3.39k|  status = ares_dns_parse_header(buf, flags, dnsrec, &qdcount, &ancount,
 1225|  3.39k|                                 &nscount, &arcount);
 1226|  3.39k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1226:7): [True: 37, False: 3.36k]
  ------------------
 1227|     37|    goto fail;
 1228|     37|  }
 1229|       |
 1230|       |  /* Must have questions */
 1231|  3.36k|  if (qdcount == 0) {
  ------------------
  |  Branch (1231:7): [True: 2, False: 3.36k]
  ------------------
 1232|      2|    status = ARES_EBADRESP;
 1233|      2|    goto fail;
 1234|      2|  }
 1235|       |
 1236|       |  /* XXX: this should be controlled by a flag in case we want to allow
 1237|       |   *      multiple questions.  I think mDNS allows this */
 1238|  3.36k|  if (qdcount > 1) {
  ------------------
  |  Branch (1238:7): [True: 39, False: 3.32k]
  ------------------
 1239|     39|    status = ARES_EBADRESP;
 1240|     39|    goto fail;
 1241|     39|  }
 1242|       |
 1243|       |  /* Parse questions */
 1244|  6.48k|  for (i = 0; i < qdcount; i++) {
  ------------------
  |  Branch (1244:15): [True: 3.32k, False: 3.16k]
  ------------------
 1245|  3.32k|    status = ares_dns_parse_qd(buf, *dnsrec);
 1246|  3.32k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1246:9): [True: 154, False: 3.16k]
  ------------------
 1247|    154|      goto fail;
 1248|    154|    }
 1249|  3.32k|  }
 1250|       |
 1251|  3.16k|  total_rr_count = (size_t)ancount + (size_t)nscount + (size_t)arcount;
 1252|  3.16k|  if (total_rr_count > ares_buf_len(buf) / min_rr_wire_len) {
  ------------------
  |  Branch (1252:7): [True: 1.01k, False: 2.14k]
  ------------------
 1253|  1.01k|    status = ARES_EBADRESP;
 1254|  1.01k|    goto fail;
 1255|  1.01k|  }
 1256|       |
 1257|  2.14k|  if (ancount > 0) {
  ------------------
  |  Branch (1257:7): [True: 1.34k, False: 802]
  ------------------
 1258|  1.34k|    status = ares_dns_record_rr_prealloc(*dnsrec, ARES_SECTION_ANSWER, ancount);
 1259|  1.34k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1259:9): [True: 0, False: 1.34k]
  ------------------
 1260|      0|      goto fail; /* LCOV_EXCL_LINE: OutOfMemory */
 1261|      0|    }
 1262|  1.34k|  }
 1263|       |
 1264|  2.14k|  if (nscount > 0) {
  ------------------
  |  Branch (1264:7): [True: 828, False: 1.32k]
  ------------------
 1265|    828|    status =
 1266|    828|      ares_dns_record_rr_prealloc(*dnsrec, ARES_SECTION_AUTHORITY, nscount);
 1267|    828|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1267:9): [True: 0, False: 828]
  ------------------
 1268|      0|      goto fail; /* LCOV_EXCL_LINE: OutOfMemory */
 1269|      0|    }
 1270|    828|  }
 1271|       |
 1272|  2.14k|  if (arcount > 0) {
  ------------------
  |  Branch (1272:7): [True: 729, False: 1.41k]
  ------------------
 1273|    729|    status =
 1274|    729|      ares_dns_record_rr_prealloc(*dnsrec, ARES_SECTION_ADDITIONAL, arcount);
 1275|    729|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1275:9): [True: 0, False: 729]
  ------------------
 1276|      0|      goto fail; /* LCOV_EXCL_LINE: OutOfMemory */
 1277|      0|    }
 1278|    729|  }
 1279|       |
 1280|       |  /* Parse Answers */
 1281|  18.9k|  for (i = 0; i < ancount; i++) {
  ------------------
  |  Branch (1281:15): [True: 16.9k, False: 1.95k]
  ------------------
 1282|  16.9k|    status = ares_dns_parse_rr(buf, flags, ARES_SECTION_ANSWER, *dnsrec);
 1283|  16.9k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1283:9): [True: 198, False: 16.7k]
  ------------------
 1284|    198|      goto fail;
 1285|    198|    }
 1286|  16.9k|  }
 1287|       |
 1288|       |  /* Parse Authority */
 1289|  19.5k|  for (i = 0; i < nscount; i++) {
  ------------------
  |  Branch (1289:15): [True: 17.6k, False: 1.89k]
  ------------------
 1290|  17.6k|    status = ares_dns_parse_rr(buf, flags, ARES_SECTION_AUTHORITY, *dnsrec);
 1291|  17.6k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1291:9): [True: 59, False: 17.5k]
  ------------------
 1292|     59|      goto fail;
 1293|     59|    }
 1294|  17.6k|  }
 1295|       |
 1296|       |  /* Parse Additional */
 1297|  31.6k|  for (i = 0; i < arcount; i++) {
  ------------------
  |  Branch (1297:15): [True: 29.7k, False: 1.82k]
  ------------------
 1298|  29.7k|    status = ares_dns_parse_rr(buf, flags, ARES_SECTION_ADDITIONAL, *dnsrec);
 1299|  29.7k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1299:9): [True: 69, False: 29.7k]
  ------------------
 1300|     69|      goto fail;
 1301|     69|    }
 1302|  29.7k|  }
 1303|       |
 1304|       |  /* Finalize rcode now that if we have OPT it is processed */
 1305|  1.82k|  if (!ares_dns_rcode_isvalid((*dnsrec)->raw_rcode)) {
  ------------------
  |  Branch (1305:7): [True: 360, False: 1.46k]
  ------------------
 1306|    360|    (*dnsrec)->rcode = ARES_RCODE_SERVFAIL;
 1307|  1.46k|  } else {
 1308|  1.46k|    (*dnsrec)->rcode = (ares_dns_rcode_t)(*dnsrec)->raw_rcode;
 1309|  1.46k|  }
 1310|       |
 1311|  1.82k|  return ARES_SUCCESS;
 1312|       |
 1313|  1.57k|fail:
 1314|  1.57k|  ares_dns_record_destroy(*dnsrec);
 1315|       |  *dnsrec = NULL;
 1316|  1.57k|  return status;
 1317|  1.89k|}
ares_dns_parse.c:ares_dns_parse_header:
  801|  3.39k|{
  802|  3.39k|  ares_status_t     status = ARES_EBADRESP;
  803|  3.39k|  unsigned short    u16;
  804|  3.39k|  unsigned short    id;
  805|  3.39k|  unsigned short    dns_flags = 0;
  806|  3.39k|  ares_dns_opcode_t opcode;
  807|  3.39k|  unsigned short    rcode;
  808|       |
  809|  3.39k|  (void)flags; /* currently unused */
  810|       |
  811|  3.39k|  if (buf == NULL || dnsrec == NULL || qdcount == NULL || ancount == NULL ||
  ------------------
  |  Branch (811:7): [True: 0, False: 3.39k]
  |  Branch (811:22): [True: 0, False: 3.39k]
  |  Branch (811:40): [True: 0, False: 3.39k]
  |  Branch (811:59): [True: 0, False: 3.39k]
  ------------------
  812|  3.39k|      nscount == NULL || arcount == NULL) {
  ------------------
  |  Branch (812:7): [True: 0, False: 3.39k]
  |  Branch (812:26): [True: 0, False: 3.39k]
  ------------------
  813|      0|    return ARES_EFORMERR;
  814|      0|  }
  815|       |
  816|  3.39k|  *dnsrec = NULL;
  817|       |
  818|       |  /*
  819|       |   *  RFC 1035 4.1.1. Header section format.
  820|       |   *  and Updated by RFC 2065 to add AD and CD bits.
  821|       |   *                                  1  1  1  1  1  1
  822|       |   *    0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
  823|       |   *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  824|       |   *  |                      ID                       |
  825|       |   *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  826|       |   *  |QR|   Opcode  |AA|TC|RD|RA| Z|AD|CD|   RCODE   |
  827|       |   *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  828|       |   *  |                    QDCOUNT                    |
  829|       |   *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  830|       |   *  |                    ANCOUNT                    |
  831|       |   *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  832|       |   *  |                    NSCOUNT                    |
  833|       |   *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  834|       |   *  |                    ARCOUNT                    |
  835|       |   *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  836|       |   */
  837|       |
  838|       |  /* ID */
  839|  3.39k|  status = ares_buf_fetch_be16(buf, &id);
  840|  3.39k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (840:7): [True: 1, False: 3.39k]
  ------------------
  841|      1|    goto fail;
  842|      1|  }
  843|       |
  844|       |  /* Flags */
  845|  3.39k|  status = ares_buf_fetch_be16(buf, &u16);
  846|  3.39k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (846:7): [True: 2, False: 3.39k]
  ------------------
  847|      2|    goto fail;
  848|      2|  }
  849|       |
  850|       |  /* QR */
  851|  3.39k|  if (u16 & 0x8000) {
  ------------------
  |  Branch (851:7): [True: 1.04k, False: 2.35k]
  ------------------
  852|  1.04k|    dns_flags |= ARES_FLAG_QR;
  853|  1.04k|  }
  854|       |
  855|       |  /* OPCODE */
  856|  3.39k|  opcode = (u16 >> 11) & 0xf;
  857|       |
  858|       |  /* AA */
  859|  3.39k|  if (u16 & 0x400) {
  ------------------
  |  Branch (859:7): [True: 813, False: 2.58k]
  ------------------
  860|    813|    dns_flags |= ARES_FLAG_AA;
  861|    813|  }
  862|       |
  863|       |  /* TC */
  864|  3.39k|  if (u16 & 0x200) {
  ------------------
  |  Branch (864:7): [True: 727, False: 2.66k]
  ------------------
  865|    727|    dns_flags |= ARES_FLAG_TC;
  866|    727|  }
  867|       |
  868|       |  /* RD */
  869|  3.39k|  if (u16 & 0x100) {
  ------------------
  |  Branch (869:7): [True: 1.45k, False: 1.94k]
  ------------------
  870|  1.45k|    dns_flags |= ARES_FLAG_RD;
  871|  1.45k|  }
  872|       |
  873|       |  /* RA */
  874|  3.39k|  if (u16 & 0x80) {
  ------------------
  |  Branch (874:7): [True: 1.19k, False: 2.20k]
  ------------------
  875|  1.19k|    dns_flags |= ARES_FLAG_RA;
  876|  1.19k|  }
  877|       |
  878|       |  /* Z -- unused */
  879|       |
  880|       |  /* AD */
  881|  3.39k|  if (u16 & 0x20) {
  ------------------
  |  Branch (881:7): [True: 860, False: 2.53k]
  ------------------
  882|    860|    dns_flags |= ARES_FLAG_AD;
  883|    860|  }
  884|       |
  885|       |  /* CD */
  886|  3.39k|  if (u16 & 0x10) {
  ------------------
  |  Branch (886:7): [True: 754, False: 2.64k]
  ------------------
  887|    754|    dns_flags |= ARES_FLAG_CD;
  888|    754|  }
  889|       |
  890|       |  /* RCODE */
  891|  3.39k|  rcode = u16 & 0xf;
  892|       |
  893|       |  /* QDCOUNT */
  894|  3.39k|  status = ares_buf_fetch_be16(buf, qdcount);
  895|  3.39k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (895:7): [True: 27, False: 3.36k]
  ------------------
  896|     27|    goto fail;
  897|     27|  }
  898|       |
  899|       |  /* ANCOUNT */
  900|  3.36k|  status = ares_buf_fetch_be16(buf, ancount);
  901|  3.36k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (901:7): [True: 2, False: 3.36k]
  ------------------
  902|      2|    goto fail;
  903|      2|  }
  904|       |
  905|       |  /* NSCOUNT */
  906|  3.36k|  status = ares_buf_fetch_be16(buf, nscount);
  907|  3.36k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (907:7): [True: 2, False: 3.36k]
  ------------------
  908|      2|    goto fail;
  909|      2|  }
  910|       |
  911|       |  /* ARCOUNT */
  912|  3.36k|  status = ares_buf_fetch_be16(buf, arcount);
  913|  3.36k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (913:7): [True: 1, False: 3.36k]
  ------------------
  914|      1|    goto fail;
  915|      1|  }
  916|       |
  917|  3.36k|  status = ares_dns_record_create(dnsrec, id, dns_flags, opcode,
  918|  3.36k|                                  ARES_RCODE_NOERROR /* Temporary */);
  919|  3.36k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (919:7): [True: 2, False: 3.36k]
  ------------------
  920|      2|    goto fail;
  921|      2|  }
  922|       |
  923|  3.36k|  (*dnsrec)->raw_rcode = rcode;
  924|       |
  925|  3.36k|  return ARES_SUCCESS;
  926|       |
  927|     37|fail:
  928|     37|  ares_dns_record_destroy(*dnsrec);
  929|     37|  *dnsrec  = NULL;
  930|     37|  *qdcount = 0;
  931|     37|  *ancount = 0;
  932|     37|  *nscount = 0;
  933|     37|  *arcount = 0;
  934|       |
  935|     37|  return status;
  936|  3.36k|}
ares_dns_parse.c:ares_dns_parse_qd:
  990|  3.32k|{
  991|  3.32k|  char               *name = NULL;
  992|  3.32k|  unsigned short      u16;
  993|  3.32k|  ares_status_t       status;
  994|  3.32k|  ares_dns_rec_type_t type;
  995|  3.32k|  ares_dns_class_t    qclass;
  996|       |  /* The question section is used to carry the "question" in most queries,
  997|       |   * i.e., the parameters that define what is being asked.  The section
  998|       |   * contains QDCOUNT (usually 1) entries, each of the following format:
  999|       |   *                                 1  1  1  1  1  1
 1000|       |   *   0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
 1001|       |   * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 1002|       |   * |                                               |
 1003|       |   * /                     QNAME                     /
 1004|       |   * /                                               /
 1005|       |   * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 1006|       |   * |                     QTYPE                     |
 1007|       |   * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 1008|       |   * |                     QCLASS                    |
 1009|       |   * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 1010|       |   */
 1011|       |
 1012|       |  /* Name */
 1013|  3.32k|  status = ares_dns_name_parse(buf, &name, ARES_FALSE);
 1014|  3.32k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1014:7): [True: 103, False: 3.21k]
  ------------------
 1015|    103|    goto done;
 1016|    103|  }
 1017|       |
 1018|       |  /* Type */
 1019|  3.21k|  status = ares_buf_fetch_be16(buf, &u16);
 1020|  3.21k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1020:7): [True: 23, False: 3.19k]
  ------------------
 1021|     23|    goto done;
 1022|     23|  }
 1023|  3.19k|  type = u16;
 1024|       |
 1025|       |  /* Class */
 1026|  3.19k|  status = ares_buf_fetch_be16(buf, &u16);
 1027|  3.19k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1027:7): [True: 3, False: 3.19k]
  ------------------
 1028|      3|    goto done;
 1029|      3|  }
 1030|  3.19k|  qclass = u16;
 1031|       |
 1032|       |  /* Add question */
 1033|  3.19k|  status = ares_dns_record_query_add(dnsrec, name, type, qclass);
 1034|  3.19k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1034:7): [True: 25, False: 3.16k]
  ------------------
 1035|     25|    goto done;
 1036|     25|  }
 1037|       |
 1038|  3.32k|done:
 1039|  3.32k|  ares_free(name);
 1040|  3.32k|  return status;
 1041|  3.19k|}
ares_dns_parse.c:ares_dns_parse_rr:
 1046|  64.3k|{
 1047|  64.3k|  char               *name = NULL;
 1048|  64.3k|  unsigned short      u16;
 1049|  64.3k|  unsigned short      raw_type;
 1050|  64.3k|  ares_status_t       status;
 1051|  64.3k|  ares_dns_rec_type_t type;
 1052|  64.3k|  ares_dns_class_t    qclass;
 1053|  64.3k|  unsigned int        ttl;
 1054|  64.3k|  size_t              rdlength;
 1055|  64.3k|  ares_dns_rr_t      *rr            = NULL;
 1056|  64.3k|  size_t              remaining_len = 0;
 1057|  64.3k|  size_t              processed_len = 0;
 1058|  64.3k|  ares_bool_t         namecomp;
 1059|       |
 1060|       |  /* All RRs have the same top level format shown below:
 1061|       |   *                                 1  1  1  1  1  1
 1062|       |   *   0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
 1063|       |   * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 1064|       |   * |                                               |
 1065|       |   * /                                               /
 1066|       |   * /                      NAME                     /
 1067|       |   * |                                               |
 1068|       |   * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 1069|       |   * |                      TYPE                     |
 1070|       |   * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 1071|       |   * |                     CLASS                     |
 1072|       |   * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 1073|       |   * |                      TTL                      |
 1074|       |   * |                                               |
 1075|       |   * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 1076|       |   * |                   RDLENGTH                    |
 1077|       |   * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
 1078|       |   * /                     RDATA                     /
 1079|       |   * /                                               /
 1080|       |   * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 1081|       |   */
 1082|       |
 1083|       |  /* Name */
 1084|  64.3k|  status = ares_dns_name_parse(buf, &name, ARES_FALSE);
 1085|  64.3k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1085:7): [True: 74, False: 64.3k]
  ------------------
 1086|     74|    goto done;
 1087|     74|  }
 1088|       |
 1089|       |  /* Type */
 1090|  64.3k|  status = ares_buf_fetch_be16(buf, &u16);
 1091|  64.3k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1091:7): [True: 14, False: 64.2k]
  ------------------
 1092|     14|    goto done;
 1093|     14|  }
 1094|  64.2k|  type     = u16;
 1095|  64.2k|  raw_type = u16; /* Only used for raw rr data */
 1096|       |
 1097|       |  /* Class */
 1098|  64.2k|  status = ares_buf_fetch_be16(buf, &u16);
 1099|  64.2k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1099:7): [True: 7, False: 64.2k]
  ------------------
 1100|      7|    goto done;
 1101|      7|  }
 1102|  64.2k|  qclass = u16;
 1103|       |
 1104|       |  /* TTL */
 1105|  64.2k|  status = ares_buf_fetch_be32(buf, &ttl);
 1106|  64.2k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1106:7): [True: 8, False: 64.2k]
  ------------------
 1107|      8|    goto done;
 1108|      8|  }
 1109|       |
 1110|       |  /* Length */
 1111|  64.2k|  status = ares_buf_fetch_be16(buf, &u16);
 1112|  64.2k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1112:7): [True: 0, False: 64.2k]
  ------------------
 1113|      0|    goto done;
 1114|      0|  }
 1115|  64.2k|  rdlength = u16;
 1116|       |
 1117|  64.2k|  if (!ares_dns_rec_type_isvalid(type, ARES_FALSE)) {
  ------------------
  |  Branch (1117:7): [True: 36.3k, False: 27.9k]
  ------------------
 1118|  36.3k|    type = ARES_REC_TYPE_RAW_RR;
 1119|  36.3k|  }
 1120|       |
 1121|  64.2k|  namecomp = ares_dns_rec_allow_name_comp(type);
 1122|  64.2k|  if (sect == ARES_SECTION_ANSWER &&
  ------------------
  |  Branch (1122:7): [True: 16.9k, False: 47.3k]
  ------------------
 1123|  16.9k|      (flags &
  ------------------
  |  Branch (1123:7): [True: 0, False: 16.9k]
  ------------------
 1124|  16.9k|       (namecomp ? ARES_DNS_PARSE_AN_BASE_RAW : ARES_DNS_PARSE_AN_EXT_RAW))) {
  ------------------
  |  Branch (1124:9): [True: 5.22k, False: 11.7k]
  ------------------
 1125|      0|    type = ARES_REC_TYPE_RAW_RR;
 1126|      0|  }
 1127|  64.2k|  if (sect == ARES_SECTION_AUTHORITY &&
  ------------------
  |  Branch (1127:7): [True: 17.5k, False: 46.6k]
  ------------------
 1128|  17.5k|      (flags &
  ------------------
  |  Branch (1128:7): [True: 0, False: 17.5k]
  ------------------
 1129|  17.5k|       (namecomp ? ARES_DNS_PARSE_NS_BASE_RAW : ARES_DNS_PARSE_NS_EXT_RAW))) {
  ------------------
  |  Branch (1129:9): [True: 2.40k, False: 15.1k]
  ------------------
 1130|      0|    type = ARES_REC_TYPE_RAW_RR;
 1131|      0|  }
 1132|  64.2k|  if (sect == ARES_SECTION_ADDITIONAL &&
  ------------------
  |  Branch (1132:7): [True: 29.7k, False: 34.5k]
  ------------------
 1133|  29.7k|      (flags &
  ------------------
  |  Branch (1133:7): [True: 0, False: 29.7k]
  ------------------
 1134|  29.7k|       (namecomp ? ARES_DNS_PARSE_AR_BASE_RAW : ARES_DNS_PARSE_AR_EXT_RAW))) {
  ------------------
  |  Branch (1134:9): [True: 3.22k, False: 26.5k]
  ------------------
 1135|      0|    type = ARES_REC_TYPE_RAW_RR;
 1136|      0|  }
 1137|       |
 1138|       |  /* Pull into another buffer for safety */
 1139|  64.2k|  if (rdlength > ares_buf_len(buf)) {
  ------------------
  |  Branch (1139:7): [True: 33, False: 64.2k]
  ------------------
 1140|     33|    status = ARES_EBADRESP;
 1141|     33|    goto done;
 1142|     33|  }
 1143|       |
 1144|       |  /* Add the base rr */
 1145|  64.2k|  status =
 1146|  64.2k|    ares_dns_record_rr_add(&rr, dnsrec, sect, name, type,
 1147|  64.2k|                           type == ARES_REC_TYPE_OPT ? ARES_CLASS_IN : qclass,
  ------------------
  |  Branch (1147:28): [True: 2.98k, False: 61.2k]
  ------------------
 1148|  64.2k|                           type == ARES_REC_TYPE_OPT ? 0 : ttl);
  ------------------
  |  Branch (1148:28): [True: 2.98k, False: 61.2k]
  ------------------
 1149|  64.2k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1149:7): [True: 4, False: 64.2k]
  ------------------
 1150|      4|    goto done;
 1151|      4|  }
 1152|       |
 1153|       |  /* Record the current remaining length in the buffer so we can tell how
 1154|       |   * much was processed */
 1155|  64.2k|  remaining_len = ares_buf_len(buf);
 1156|       |
 1157|       |  /* Fill in the data for the rr */
 1158|  64.2k|  status = ares_dns_parse_rr_data(buf, rdlength, rr, type, raw_type,
 1159|  64.2k|                                  (unsigned short)qclass, ttl);
 1160|  64.2k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1160:7): [True: 147, False: 64.0k]
  ------------------
 1161|    147|    goto done;
 1162|    147|  }
 1163|       |
 1164|       |  /* Determine how many bytes were processed */
 1165|  64.0k|  processed_len = remaining_len - ares_buf_len(buf);
 1166|       |
 1167|       |  /* If too many bytes were processed, error! */
 1168|  64.0k|  if (processed_len > rdlength) {
  ------------------
  |  Branch (1168:7): [True: 39, False: 64.0k]
  ------------------
 1169|     39|    status = ARES_EBADRESP;
 1170|     39|    goto done;
 1171|     39|  }
 1172|       |
 1173|       |  /* If too few bytes were processed, consume the unprocessed data for this
 1174|       |   * record as the parser may not have wanted/needed to use it */
 1175|  64.0k|  if (processed_len < rdlength) {
  ------------------
  |  Branch (1175:7): [True: 2.38k, False: 61.6k]
  ------------------
 1176|  2.38k|    ares_buf_consume(buf, rdlength - processed_len);
 1177|  2.38k|  }
 1178|       |
 1179|       |
 1180|  64.3k|done:
 1181|  64.3k|  ares_free(name);
 1182|  64.3k|  return status;
 1183|  64.0k|}
ares_dns_parse.c:ares_dns_parse_rr_data:
  942|  64.2k|{
  943|  64.2k|  switch (type) {
  ------------------
  |  Branch (943:11): [True: 64.2k, False: 0]
  ------------------
  944|    636|    case ARES_REC_TYPE_A:
  ------------------
  |  Branch (944:5): [True: 636, False: 63.6k]
  ------------------
  945|    636|      return ares_dns_parse_rr_a(buf, rr, rdlength);
  946|  1.31k|    case ARES_REC_TYPE_NS:
  ------------------
  |  Branch (946:5): [True: 1.31k, False: 62.9k]
  ------------------
  947|  1.31k|      return ares_dns_parse_rr_ns(buf, rr, rdlength);
  948|  1.23k|    case ARES_REC_TYPE_CNAME:
  ------------------
  |  Branch (948:5): [True: 1.23k, False: 63.0k]
  ------------------
  949|  1.23k|      return ares_dns_parse_rr_cname(buf, rr, rdlength);
  950|  1.10k|    case ARES_REC_TYPE_SOA:
  ------------------
  |  Branch (950:5): [True: 1.10k, False: 63.1k]
  ------------------
  951|  1.10k|      return ares_dns_parse_rr_soa(buf, rr, rdlength);
  952|    546|    case ARES_REC_TYPE_PTR:
  ------------------
  |  Branch (952:5): [True: 546, False: 63.6k]
  ------------------
  953|    546|      return ares_dns_parse_rr_ptr(buf, rr, rdlength);
  954|  1.40k|    case ARES_REC_TYPE_HINFO:
  ------------------
  |  Branch (954:5): [True: 1.40k, False: 62.8k]
  ------------------
  955|  1.40k|      return ares_dns_parse_rr_hinfo(buf, rr, rdlength);
  956|  3.38k|    case ARES_REC_TYPE_MX:
  ------------------
  |  Branch (956:5): [True: 3.38k, False: 60.8k]
  ------------------
  957|  3.38k|      return ares_dns_parse_rr_mx(buf, rr, rdlength);
  958|  1.21k|    case ARES_REC_TYPE_TXT:
  ------------------
  |  Branch (958:5): [True: 1.21k, False: 63.0k]
  ------------------
  959|  1.21k|      return ares_dns_parse_rr_txt(buf, rr, rdlength);
  960|  1.39k|    case ARES_REC_TYPE_SIG:
  ------------------
  |  Branch (960:5): [True: 1.39k, False: 62.8k]
  ------------------
  961|  1.39k|      return ares_dns_parse_rr_sig(buf, rr, rdlength);
  962|  6.65k|    case ARES_REC_TYPE_AAAA:
  ------------------
  |  Branch (962:5): [True: 6.65k, False: 57.5k]
  ------------------
  963|  6.65k|      return ares_dns_parse_rr_aaaa(buf, rr, rdlength);
  964|    643|    case ARES_REC_TYPE_SRV:
  ------------------
  |  Branch (964:5): [True: 643, False: 63.5k]
  ------------------
  965|    643|      return ares_dns_parse_rr_srv(buf, rr, rdlength);
  966|  1.04k|    case ARES_REC_TYPE_NAPTR:
  ------------------
  |  Branch (966:5): [True: 1.04k, False: 63.1k]
  ------------------
  967|  1.04k|      return ares_dns_parse_rr_naptr(buf, rr, rdlength);
  968|      0|    case ARES_REC_TYPE_ANY:
  ------------------
  |  Branch (968:5): [True: 0, False: 64.2k]
  ------------------
  969|      0|      return ARES_EBADRESP;
  970|  2.98k|    case ARES_REC_TYPE_OPT:
  ------------------
  |  Branch (970:5): [True: 2.98k, False: 61.2k]
  ------------------
  971|  2.98k|      return ares_dns_parse_rr_opt(buf, rr, rdlength, raw_class, raw_ttl);
  972|    663|    case ARES_REC_TYPE_TLSA:
  ------------------
  |  Branch (972:5): [True: 663, False: 63.5k]
  ------------------
  973|    663|      return ares_dns_parse_rr_tlsa(buf, rr, rdlength);
  974|  1.14k|    case ARES_REC_TYPE_SVCB:
  ------------------
  |  Branch (974:5): [True: 1.14k, False: 63.1k]
  ------------------
  975|  1.14k|      return ares_dns_parse_rr_svcb(buf, rr, rdlength);
  976|  1.05k|    case ARES_REC_TYPE_HTTPS:
  ------------------
  |  Branch (976:5): [True: 1.05k, False: 63.1k]
  ------------------
  977|  1.05k|      return ares_dns_parse_rr_https(buf, rr, rdlength);
  978|    853|    case ARES_REC_TYPE_URI:
  ------------------
  |  Branch (978:5): [True: 853, False: 63.3k]
  ------------------
  979|    853|      return ares_dns_parse_rr_uri(buf, rr, rdlength);
  980|    638|    case ARES_REC_TYPE_CAA:
  ------------------
  |  Branch (980:5): [True: 638, False: 63.6k]
  ------------------
  981|    638|      return ares_dns_parse_rr_caa(buf, rr, rdlength);
  982|  36.3k|    case ARES_REC_TYPE_RAW_RR:
  ------------------
  |  Branch (982:5): [True: 36.3k, False: 27.9k]
  ------------------
  983|  36.3k|      return ares_dns_parse_rr_raw_rr(buf, rr, rdlength, raw_type);
  984|  64.2k|  }
  985|      0|  return ARES_EFORMERR;
  986|  64.2k|}
ares_dns_parse.c:ares_dns_parse_rr_a:
  159|    636|{
  160|    636|  struct in_addr addr;
  161|    636|  ares_status_t  status;
  162|       |
  163|    636|  (void)rdlength; /* Not needed */
  164|       |
  165|    636|  status = ares_buf_fetch_bytes(buf, (unsigned char *)&addr, sizeof(addr));
  166|    636|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (166:7): [True: 0, False: 636]
  ------------------
  167|      0|    return status;
  168|      0|  }
  169|       |
  170|    636|  return ares_dns_rr_set_addr(rr, ARES_RR_A_ADDR, &addr);
  171|    636|}
ares_dns_parse.c:ares_dns_parse_rr_ns:
  175|  1.31k|{
  176|  1.31k|  (void)rdlength; /* Not needed */
  177|       |
  178|  1.31k|  return ares_dns_parse_and_set_dns_name(buf, ARES_FALSE, rr,
  179|  1.31k|                                         ARES_RR_NS_NSDNAME);
  180|  1.31k|}
ares_dns_parse.c:ares_dns_parse_and_set_dns_name:
   46|  13.9k|{
   47|  13.9k|  ares_status_t status;
   48|  13.9k|  char         *name = NULL;
   49|       |
   50|  13.9k|  status = ares_dns_name_parse(buf, &name, is_hostname);
   51|  13.9k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (51:7): [True: 12, False: 13.9k]
  ------------------
   52|     12|    return status;
   53|     12|  }
   54|       |
   55|  13.9k|  status = ares_dns_rr_set_str_own(rr, key, name);
   56|  13.9k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (56:7): [True: 0, False: 13.9k]
  ------------------
   57|      0|    ares_free(name);
   58|      0|    return status;
   59|      0|  }
   60|  13.9k|  return ARES_SUCCESS;
   61|  13.9k|}
ares_dns_parse.c:ares_dns_parse_rr_cname:
  184|  1.23k|{
  185|  1.23k|  (void)rdlength; /* Not needed */
  186|       |
  187|  1.23k|  return ares_dns_parse_and_set_dns_name(buf, ARES_FALSE, rr,
  188|  1.23k|                                         ARES_RR_CNAME_CNAME);
  189|  1.23k|}
ares_dns_parse.c:ares_dns_parse_rr_soa:
  193|  1.10k|{
  194|  1.10k|  ares_status_t status;
  195|       |
  196|  1.10k|  (void)rdlength; /* Not needed */
  197|       |
  198|       |  /* MNAME */
  199|  1.10k|  status =
  200|  1.10k|    ares_dns_parse_and_set_dns_name(buf, ARES_FALSE, rr, ARES_RR_SOA_MNAME);
  201|  1.10k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (201:7): [True: 0, False: 1.10k]
  ------------------
  202|      0|    return status;
  203|      0|  }
  204|       |
  205|       |  /* RNAME */
  206|  1.10k|  status =
  207|  1.10k|    ares_dns_parse_and_set_dns_name(buf, ARES_FALSE, rr, ARES_RR_SOA_RNAME);
  208|  1.10k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (208:7): [True: 3, False: 1.10k]
  ------------------
  209|      3|    return status;
  210|      3|  }
  211|       |
  212|       |  /* SERIAL */
  213|  1.10k|  status = ares_dns_parse_and_set_be32(buf, rr, ARES_RR_SOA_SERIAL);
  214|  1.10k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (214:7): [True: 1, False: 1.10k]
  ------------------
  215|      1|    return status;
  216|      1|  }
  217|       |
  218|       |  /* REFRESH */
  219|  1.10k|  status = ares_dns_parse_and_set_be32(buf, rr, ARES_RR_SOA_REFRESH);
  220|  1.10k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (220:7): [True: 1, False: 1.10k]
  ------------------
  221|      1|    return status;
  222|      1|  }
  223|       |
  224|       |  /* RETRY */
  225|  1.10k|  status = ares_dns_parse_and_set_be32(buf, rr, ARES_RR_SOA_RETRY);
  226|  1.10k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (226:7): [True: 0, False: 1.10k]
  ------------------
  227|      0|    return status;
  228|      0|  }
  229|       |
  230|       |  /* EXPIRE */
  231|  1.10k|  status = ares_dns_parse_and_set_be32(buf, rr, ARES_RR_SOA_EXPIRE);
  232|  1.10k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (232:7): [True: 1, False: 1.10k]
  ------------------
  233|      1|    return status;
  234|      1|  }
  235|       |
  236|       |  /* MINIMUM */
  237|  1.10k|  return ares_dns_parse_and_set_be32(buf, rr, ARES_RR_SOA_MINIMUM);
  238|  1.10k|}
ares_dns_parse.c:ares_dns_parse_and_set_be32:
  115|  9.68k|{
  116|  9.68k|  ares_status_t status;
  117|  9.68k|  unsigned int  u32;
  118|       |
  119|  9.68k|  status = ares_buf_fetch_be32(buf, &u32);
  120|  9.68k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (120:7): [True: 4, False: 9.68k]
  ------------------
  121|      4|    return status;
  122|      4|  }
  123|       |
  124|  9.68k|  return ares_dns_rr_set_u32(rr, key, u32);
  125|  9.68k|}
ares_dns_parse.c:ares_dns_parse_rr_ptr:
  242|    546|{
  243|    546|  (void)rdlength; /* Not needed */
  244|       |
  245|    546|  return ares_dns_parse_and_set_dns_name(buf, ARES_FALSE, rr,
  246|    546|                                         ARES_RR_PTR_DNAME);
  247|    546|}
ares_dns_parse.c:ares_dns_parse_rr_hinfo:
  251|  1.40k|{
  252|  1.40k|  ares_status_t status;
  253|  1.40k|  size_t        orig_len = ares_buf_len(buf);
  254|       |
  255|  1.40k|  (void)rdlength; /* Not needed */
  256|       |
  257|       |  /* CPU */
  258|  1.40k|  status = ares_dns_parse_and_set_dns_str(
  259|  1.40k|    buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), rr,
  260|  1.40k|    ARES_RR_HINFO_CPU, ARES_TRUE);
  261|  1.40k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (261:7): [True: 7, False: 1.39k]
  ------------------
  262|      7|    return status;
  263|      7|  }
  264|       |
  265|       |  /* OS */
  266|  1.39k|  status = ares_dns_parse_and_set_dns_str(
  267|  1.39k|    buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), rr,
  268|  1.39k|    ARES_RR_HINFO_OS, ARES_TRUE);
  269|       |
  270|  1.39k|  return status;
  271|  1.40k|}
ares_dns_parse.c:ares_dns_parse_and_set_dns_str:
   68|  6.57k|{
   69|  6.57k|  ares_status_t status;
   70|  6.57k|  char         *str = NULL;
   71|       |
   72|  6.57k|  status = ares_buf_parse_dns_str(buf, max_len, &str);
   73|  6.57k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (73:7): [True: 35, False: 6.53k]
  ------------------
   74|     35|    return status;
   75|     35|  }
   76|       |
   77|  6.53k|  if (!blank_allowed && ares_strlen(str) == 0) {
  ------------------
  |  Branch (77:7): [True: 630, False: 5.90k]
  |  Branch (77:25): [True: 3, False: 627]
  ------------------
   78|      3|    ares_free(str);
   79|      3|    return ARES_EBADRESP;
   80|      3|  }
   81|       |
   82|  6.53k|  status = ares_dns_rr_set_str_own(rr, key, str);
   83|  6.53k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (83:7): [True: 0, False: 6.53k]
  ------------------
   84|      0|    ares_free(str);
   85|      0|    return status;
   86|      0|  }
   87|  6.53k|  return ARES_SUCCESS;
   88|  6.53k|}
ares_dns_parse.c:ares_dns_rr_remaining_len:
   34|  24.4k|{
   35|  24.4k|  size_t used_len = orig_len - ares_buf_len(buf);
   36|  24.4k|  if (used_len >= rdlength) {
  ------------------
  |  Branch (36:7): [True: 5.16k, False: 19.3k]
  ------------------
   37|  5.16k|    return 0;
   38|  5.16k|  }
   39|  19.3k|  return rdlength - used_len;
   40|  24.4k|}
ares_dns_parse.c:ares_dns_parse_rr_mx:
  275|  3.38k|{
  276|  3.38k|  ares_status_t status;
  277|       |
  278|  3.38k|  (void)rdlength; /* Not needed */
  279|       |
  280|       |  /* PREFERENCE */
  281|  3.38k|  status = ares_dns_parse_and_set_be16(buf, rr, ARES_RR_MX_PREFERENCE);
  282|  3.38k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (282:7): [True: 1, False: 3.38k]
  ------------------
  283|      1|    return status;
  284|      1|  }
  285|       |
  286|       |  /* EXCHANGE */
  287|  3.38k|  return ares_dns_parse_and_set_dns_name(buf, ARES_FALSE, rr,
  288|  3.38k|                                         ARES_RR_MX_EXCHANGE);
  289|  3.38k|}
ares_dns_parse.c:ares_dns_parse_and_set_be16:
  130|  14.1k|{
  131|  14.1k|  ares_status_t  status;
  132|  14.1k|  unsigned short u16;
  133|       |
  134|  14.1k|  status = ares_buf_fetch_be16(buf, &u16);
  135|  14.1k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (135:7): [True: 4, False: 14.0k]
  ------------------
  136|      4|    return status;
  137|      4|  }
  138|       |
  139|  14.0k|  return ares_dns_rr_set_u16(rr, key, u16);
  140|  14.1k|}
ares_dns_parse.c:ares_dns_parse_rr_txt:
  293|  1.21k|{
  294|  1.21k|  return ares_dns_parse_and_set_dns_abin(buf, rdlength, rr, ARES_RR_TXT_DATA,
  295|  1.21k|                                         ARES_FALSE);
  296|  1.21k|}
ares_dns_parse.c:ares_dns_parse_and_set_dns_abin:
   94|  1.21k|{
   95|  1.21k|  ares_status_t           status;
   96|  1.21k|  ares_dns_multistring_t *strs = NULL;
   97|       |
   98|  1.21k|  status =
   99|  1.21k|    ares_dns_multistring_parse_buf(buf, max_len, &strs, validate_printable);
  100|  1.21k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (100:7): [True: 14, False: 1.20k]
  ------------------
  101|     14|    return status;
  102|     14|  }
  103|       |
  104|  1.20k|  status = ares_dns_rr_set_abin_own(rr, key, strs);
  105|  1.20k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (105:7): [True: 0, False: 1.20k]
  ------------------
  106|      0|    ares_dns_multistring_destroy(strs);
  107|      0|    return status;
  108|      0|  }
  109|  1.20k|  return ARES_SUCCESS;
  110|  1.20k|}
ares_dns_parse.c:ares_dns_parse_rr_sig:
  300|  1.39k|{
  301|  1.39k|  ares_status_t  status;
  302|  1.39k|  size_t         orig_len = ares_buf_len(buf);
  303|  1.39k|  size_t         len;
  304|  1.39k|  unsigned char *data;
  305|       |
  306|  1.39k|  status = ares_dns_parse_and_set_be16(buf, rr, ARES_RR_SIG_TYPE_COVERED);
  307|  1.39k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (307:7): [True: 0, False: 1.39k]
  ------------------
  308|      0|    return status;
  309|      0|  }
  310|       |
  311|  1.39k|  status = ares_dns_parse_and_set_u8(buf, rr, ARES_RR_SIG_ALGORITHM);
  312|  1.39k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (312:7): [True: 3, False: 1.39k]
  ------------------
  313|      3|    return status;
  314|      3|  }
  315|       |
  316|  1.39k|  status = ares_dns_parse_and_set_u8(buf, rr, ARES_RR_SIG_LABELS);
  317|  1.39k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (317:7): [True: 0, False: 1.39k]
  ------------------
  318|      0|    return status;
  319|      0|  }
  320|       |
  321|  1.39k|  status = ares_dns_parse_and_set_be32(buf, rr, ARES_RR_SIG_ORIGINAL_TTL);
  322|  1.39k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (322:7): [True: 0, False: 1.39k]
  ------------------
  323|      0|    return status;
  324|      0|  }
  325|       |
  326|  1.39k|  status = ares_dns_parse_and_set_be32(buf, rr, ARES_RR_SIG_EXPIRATION);
  327|  1.39k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (327:7): [True: 1, False: 1.39k]
  ------------------
  328|      1|    return status;
  329|      1|  }
  330|       |
  331|  1.39k|  status = ares_dns_parse_and_set_be32(buf, rr, ARES_RR_SIG_INCEPTION);
  332|  1.39k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (332:7): [True: 0, False: 1.39k]
  ------------------
  333|      0|    return status;
  334|      0|  }
  335|       |
  336|  1.39k|  status = ares_dns_parse_and_set_be16(buf, rr, ARES_RR_SIG_KEY_TAG);
  337|  1.39k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (337:7): [True: 0, False: 1.39k]
  ------------------
  338|      0|    return status;
  339|      0|  }
  340|       |
  341|  1.39k|  status = ares_dns_parse_and_set_dns_name(buf, ARES_FALSE, rr,
  342|  1.39k|                                           ARES_RR_SIG_SIGNERS_NAME);
  343|  1.39k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (343:7): [True: 0, False: 1.39k]
  ------------------
  344|      0|    return status;
  345|      0|  }
  346|       |
  347|  1.39k|  len = ares_dns_rr_remaining_len(buf, orig_len, rdlength);
  348|  1.39k|  if (len == 0) {
  ------------------
  |  Branch (348:7): [True: 11, False: 1.37k]
  ------------------
  349|     11|    return ARES_EBADRESP;
  350|     11|  }
  351|       |
  352|  1.37k|  status = ares_buf_fetch_bytes_dup(buf, len, ARES_FALSE, &data);
  353|  1.37k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (353:7): [True: 0, False: 1.37k]
  ------------------
  354|      0|    return status;
  355|      0|  }
  356|       |
  357|  1.37k|  status = ares_dns_rr_set_bin_own(rr, ARES_RR_SIG_SIGNATURE, data, len);
  358|  1.37k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (358:7): [True: 0, False: 1.37k]
  ------------------
  359|      0|    ares_free(data);
  360|      0|    return status;
  361|      0|  }
  362|       |
  363|  1.37k|  return ARES_SUCCESS;
  364|  1.37k|}
ares_dns_parse.c:ares_dns_parse_and_set_u8:
  145|  5.41k|{
  146|  5.41k|  ares_status_t status;
  147|  5.41k|  unsigned char u8;
  148|       |
  149|  5.41k|  status = ares_buf_fetch_bytes(buf, &u8, 1);
  150|  5.41k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (150:7): [True: 5, False: 5.40k]
  ------------------
  151|      5|    return status;
  152|      5|  }
  153|       |
  154|  5.40k|  return ares_dns_rr_set_u8(rr, key, u8);
  155|  5.41k|}
ares_dns_parse.c:ares_dns_parse_rr_aaaa:
  368|  6.65k|{
  369|  6.65k|  struct ares_in6_addr addr;
  370|  6.65k|  ares_status_t        status;
  371|       |
  372|  6.65k|  (void)rdlength; /* Not needed */
  373|       |
  374|  6.65k|  status = ares_buf_fetch_bytes(buf, (unsigned char *)&addr, sizeof(addr));
  375|  6.65k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (375:7): [True: 0, False: 6.65k]
  ------------------
  376|      0|    return status;
  377|      0|  }
  378|       |
  379|  6.65k|  return ares_dns_rr_set_addr6(rr, ARES_RR_AAAA_ADDR, &addr);
  380|  6.65k|}
ares_dns_parse.c:ares_dns_parse_rr_srv:
  384|    643|{
  385|    643|  ares_status_t status;
  386|       |
  387|    643|  (void)rdlength; /* Not needed */
  388|       |
  389|       |  /* PRIORITY */
  390|    643|  status = ares_dns_parse_and_set_be16(buf, rr, ARES_RR_SRV_PRIORITY);
  391|    643|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (391:7): [True: 0, False: 643]
  ------------------
  392|      0|    return status;
  393|      0|  }
  394|       |
  395|       |  /* WEIGHT */
  396|    643|  status = ares_dns_parse_and_set_be16(buf, rr, ARES_RR_SRV_WEIGHT);
  397|    643|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (397:7): [True: 1, False: 642]
  ------------------
  398|      1|    return status;
  399|      1|  }
  400|       |
  401|       |  /* PORT */
  402|    642|  status = ares_dns_parse_and_set_be16(buf, rr, ARES_RR_SRV_PORT);
  403|    642|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (403:7): [True: 1, False: 641]
  ------------------
  404|      1|    return status;
  405|      1|  }
  406|       |
  407|       |  /* TARGET */
  408|    641|  return ares_dns_parse_and_set_dns_name(buf, ARES_FALSE, rr,
  409|    641|                                         ARES_RR_SRV_TARGET);
  410|    642|}
ares_dns_parse.c:ares_dns_parse_rr_naptr:
  414|  1.04k|{
  415|  1.04k|  ares_status_t status;
  416|  1.04k|  size_t        orig_len = ares_buf_len(buf);
  417|       |
  418|       |  /* ORDER */
  419|  1.04k|  status = ares_dns_parse_and_set_be16(buf, rr, ARES_RR_NAPTR_ORDER);
  420|  1.04k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (420:7): [True: 0, False: 1.04k]
  ------------------
  421|      0|    return status;
  422|      0|  }
  423|       |
  424|       |  /* PREFERENCE */
  425|  1.04k|  status = ares_dns_parse_and_set_be16(buf, rr, ARES_RR_NAPTR_PREFERENCE);
  426|  1.04k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (426:7): [True: 1, False: 1.04k]
  ------------------
  427|      1|    return status;
  428|      1|  }
  429|       |
  430|       |  /* FLAGS */
  431|  1.04k|  status = ares_dns_parse_and_set_dns_str(
  432|  1.04k|    buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), rr,
  433|  1.04k|    ARES_RR_NAPTR_FLAGS, ARES_TRUE);
  434|  1.04k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (434:7): [True: 1, False: 1.04k]
  ------------------
  435|      1|    return status;
  436|      1|  }
  437|       |
  438|       |  /* SERVICES */
  439|  1.04k|  status = ares_dns_parse_and_set_dns_str(
  440|  1.04k|    buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), rr,
  441|  1.04k|    ARES_RR_NAPTR_SERVICES, ARES_TRUE);
  442|  1.04k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (442:7): [True: 1, False: 1.04k]
  ------------------
  443|      1|    return status;
  444|      1|  }
  445|       |
  446|       |  /* REGEXP */
  447|  1.04k|  status = ares_dns_parse_and_set_dns_str(
  448|  1.04k|    buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), rr,
  449|  1.04k|    ARES_RR_NAPTR_REGEXP, ARES_TRUE);
  450|  1.04k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (450:7): [True: 5, False: 1.04k]
  ------------------
  451|      5|    return status;
  452|      5|  }
  453|       |
  454|       |  /* REPLACEMENT */
  455|  1.04k|  return ares_dns_parse_and_set_dns_name(buf, ARES_FALSE, rr,
  456|  1.04k|                                         ARES_RR_NAPTR_REPLACEMENT);
  457|  1.04k|}
ares_dns_parse.c:ares_dns_parse_rr_opt:
  463|  2.98k|{
  464|  2.98k|  ares_status_t  status;
  465|  2.98k|  size_t         orig_len = ares_buf_len(buf);
  466|  2.98k|  unsigned short rcode_high;
  467|       |
  468|  2.98k|  status = ares_dns_rr_set_u16(rr, ARES_RR_OPT_UDP_SIZE, raw_class);
  469|  2.98k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (469:7): [True: 0, False: 2.98k]
  ------------------
  470|      0|    return status;
  471|      0|  }
  472|       |
  473|       |  /* First 8 bits of TTL are an extended RCODE, and they go in the higher order
  474|       |   * after the original 4-bit rcode */
  475|  2.98k|  rcode_high             = (unsigned short)((raw_ttl >> 20) & 0x0FF0);
  476|  2.98k|  rr->parent->raw_rcode |= rcode_high;
  477|       |
  478|  2.98k|  status = ares_dns_rr_set_u8(rr, ARES_RR_OPT_VERSION,
  479|  2.98k|                              (unsigned char)(raw_ttl >> 16) & 0xFF);
  480|  2.98k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (480:7): [True: 0, False: 2.98k]
  ------------------
  481|      0|    return status;
  482|      0|  }
  483|       |
  484|  2.98k|  status = ares_dns_rr_set_u16(rr, ARES_RR_OPT_FLAGS,
  485|  2.98k|                               (unsigned short)(raw_ttl & 0xFFFF));
  486|  2.98k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (486:7): [True: 0, False: 2.98k]
  ------------------
  487|      0|    return status;
  488|      0|  }
  489|       |
  490|       |  /* Parse options */
  491|  5.76k|  while (ares_dns_rr_remaining_len(buf, orig_len, rdlength)) {
  ------------------
  |  Branch (491:10): [True: 2.79k, False: 2.97k]
  ------------------
  492|  2.79k|    unsigned short opt = 0;
  493|  2.79k|    unsigned short len = 0;
  494|  2.79k|    unsigned char *val = NULL;
  495|       |
  496|       |    /* Fetch be16 option */
  497|  2.79k|    status = ares_buf_fetch_be16(buf, &opt);
  498|  2.79k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (498:9): [True: 9, False: 2.78k]
  ------------------
  499|      9|      return status;
  500|      9|    }
  501|       |
  502|       |    /* Fetch be16 length */
  503|  2.78k|    status = ares_buf_fetch_be16(buf, &len);
  504|  2.78k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (504:9): [True: 1, False: 2.78k]
  ------------------
  505|      1|      return status;
  506|      1|    }
  507|       |
  508|  2.78k|    if (len) {
  ------------------
  |  Branch (508:9): [True: 304, False: 2.48k]
  ------------------
  509|    304|      status = ares_buf_fetch_bytes_dup(buf, len, ARES_TRUE, &val);
  510|    304|      if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (510:11): [True: 3, False: 301]
  ------------------
  511|      3|        return status;
  512|      3|      }
  513|    304|    }
  514|       |
  515|  2.78k|    status = ares_dns_rr_set_opt_own(rr, ARES_RR_OPT_OPTIONS, opt, val, len);
  516|  2.78k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (516:9): [True: 0, False: 2.78k]
  ------------------
  517|      0|      ares_free(val);
  518|      0|      return status;
  519|      0|    }
  520|  2.78k|  }
  521|       |
  522|  2.97k|  return ARES_SUCCESS;
  523|  2.98k|}
ares_dns_parse.c:ares_dns_parse_rr_tlsa:
  527|    663|{
  528|    663|  ares_status_t  status;
  529|    663|  size_t         orig_len = ares_buf_len(buf);
  530|    663|  size_t         len;
  531|    663|  unsigned char *data;
  532|       |
  533|    663|  status = ares_dns_parse_and_set_u8(buf, rr, ARES_RR_TLSA_CERT_USAGE);
  534|    663|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (534:7): [True: 1, False: 662]
  ------------------
  535|      1|    return status;
  536|      1|  }
  537|       |
  538|    662|  status = ares_dns_parse_and_set_u8(buf, rr, ARES_RR_TLSA_SELECTOR);
  539|    662|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (539:7): [True: 0, False: 662]
  ------------------
  540|      0|    return status;
  541|      0|  }
  542|       |
  543|    662|  status = ares_dns_parse_and_set_u8(buf, rr, ARES_RR_TLSA_MATCH);
  544|    662|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (544:7): [True: 1, False: 661]
  ------------------
  545|      1|    return status;
  546|      1|  }
  547|       |
  548|    661|  len = ares_dns_rr_remaining_len(buf, orig_len, rdlength);
  549|    661|  if (len == 0) {
  ------------------
  |  Branch (549:7): [True: 0, False: 661]
  ------------------
  550|      0|    return ARES_EBADRESP;
  551|      0|  }
  552|       |
  553|    661|  status = ares_buf_fetch_bytes_dup(buf, len, ARES_FALSE, &data);
  554|    661|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (554:7): [True: 0, False: 661]
  ------------------
  555|      0|    return status;
  556|      0|  }
  557|       |
  558|    661|  status = ares_dns_rr_set_bin_own(rr, ARES_RR_TLSA_DATA, data, len);
  559|    661|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (559:7): [True: 0, False: 661]
  ------------------
  560|      0|    ares_free(data);
  561|      0|    return status;
  562|      0|  }
  563|       |
  564|    661|  return ARES_SUCCESS;
  565|    661|}
ares_dns_parse.c:ares_dns_parse_rr_svcb:
  569|  1.14k|{
  570|  1.14k|  ares_status_t status;
  571|  1.14k|  size_t        orig_len = ares_buf_len(buf);
  572|       |
  573|  1.14k|  status = ares_dns_parse_and_set_be16(buf, rr, ARES_RR_SVCB_PRIORITY);
  574|  1.14k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (574:7): [True: 0, False: 1.14k]
  ------------------
  575|      0|    return status;
  576|      0|  }
  577|       |
  578|  1.14k|  status =
  579|  1.14k|    ares_dns_parse_and_set_dns_name(buf, ARES_FALSE, rr, ARES_RR_SVCB_TARGET);
  580|  1.14k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (580:7): [True: 1, False: 1.13k]
  ------------------
  581|      1|    return status;
  582|      1|  }
  583|       |
  584|       |  /* Parse params */
  585|  5.02k|  while (ares_dns_rr_remaining_len(buf, orig_len, rdlength)) {
  ------------------
  |  Branch (585:10): [True: 3.90k, False: 1.12k]
  ------------------
  586|  3.90k|    unsigned short opt = 0;
  587|  3.90k|    unsigned short len = 0;
  588|  3.90k|    unsigned char *val = NULL;
  589|       |
  590|       |    /* Fetch be16 option */
  591|  3.90k|    status = ares_buf_fetch_be16(buf, &opt);
  592|  3.90k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (592:9): [True: 4, False: 3.89k]
  ------------------
  593|      4|      return status;
  594|      4|    }
  595|       |
  596|       |    /* Fetch be16 length */
  597|  3.89k|    status = ares_buf_fetch_be16(buf, &len);
  598|  3.89k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (598:9): [True: 1, False: 3.89k]
  ------------------
  599|      1|      return status;
  600|      1|    }
  601|       |
  602|  3.89k|    if (len) {
  ------------------
  |  Branch (602:9): [True: 1.06k, False: 2.82k]
  ------------------
  603|  1.06k|      status = ares_buf_fetch_bytes_dup(buf, len, ARES_TRUE, &val);
  604|  1.06k|      if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (604:11): [True: 7, False: 1.06k]
  ------------------
  605|      7|        return status;
  606|      7|      }
  607|  1.06k|    }
  608|       |
  609|  3.88k|    status = ares_dns_rr_set_opt_own(rr, ARES_RR_SVCB_PARAMS, opt, val, len);
  610|  3.88k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (610:9): [True: 0, False: 3.88k]
  ------------------
  611|      0|      ares_free(val);
  612|      0|      return status;
  613|      0|    }
  614|  3.88k|  }
  615|       |
  616|  1.12k|  return ARES_SUCCESS;
  617|  1.13k|}
ares_dns_parse.c:ares_dns_parse_rr_https:
  621|  1.05k|{
  622|  1.05k|  ares_status_t status;
  623|  1.05k|  size_t        orig_len = ares_buf_len(buf);
  624|       |
  625|  1.05k|  status = ares_dns_parse_and_set_be16(buf, rr, ARES_RR_HTTPS_PRIORITY);
  626|  1.05k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (626:7): [True: 0, False: 1.05k]
  ------------------
  627|      0|    return status;
  628|      0|  }
  629|       |
  630|  1.05k|  status =
  631|  1.05k|    ares_dns_parse_and_set_dns_name(buf, ARES_FALSE, rr, ARES_RR_HTTPS_TARGET);
  632|  1.05k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (632:7): [True: 1, False: 1.05k]
  ------------------
  633|      1|    return status;
  634|      1|  }
  635|       |
  636|       |  /* Parse params */
  637|  3.57k|  while (ares_dns_rr_remaining_len(buf, orig_len, rdlength)) {
  ------------------
  |  Branch (637:10): [True: 2.52k, False: 1.05k]
  ------------------
  638|  2.52k|    unsigned short opt = 0;
  639|  2.52k|    unsigned short len = 0;
  640|  2.52k|    unsigned char *val = NULL;
  641|       |
  642|       |    /* Fetch be16 option */
  643|  2.52k|    status = ares_buf_fetch_be16(buf, &opt);
  644|  2.52k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (644:9): [True: 1, False: 2.52k]
  ------------------
  645|      1|      return status;
  646|      1|    }
  647|       |
  648|       |    /* Fetch be16 length */
  649|  2.52k|    status = ares_buf_fetch_be16(buf, &len);
  650|  2.52k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (650:9): [True: 1, False: 2.52k]
  ------------------
  651|      1|      return status;
  652|      1|    }
  653|       |
  654|  2.52k|    if (len) {
  ------------------
  |  Branch (654:9): [True: 960, False: 1.56k]
  ------------------
  655|    960|      status = ares_buf_fetch_bytes_dup(buf, len, ARES_TRUE, &val);
  656|    960|      if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (656:11): [True: 5, False: 955]
  ------------------
  657|      5|        return status;
  658|      5|      }
  659|    960|    }
  660|       |
  661|  2.51k|    status = ares_dns_rr_set_opt_own(rr, ARES_RR_HTTPS_PARAMS, opt, val, len);
  662|  2.51k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (662:9): [True: 0, False: 2.51k]
  ------------------
  663|      0|      ares_free(val);
  664|      0|      return status;
  665|      0|    }
  666|  2.51k|  }
  667|       |
  668|  1.05k|  return ARES_SUCCESS;
  669|  1.05k|}
ares_dns_parse.c:ares_dns_parse_rr_uri:
  673|    853|{
  674|    853|  char         *name = NULL;
  675|    853|  ares_status_t status;
  676|    853|  size_t        orig_len = ares_buf_len(buf);
  677|    853|  size_t        remaining_len;
  678|       |
  679|       |  /* PRIORITY */
  680|    853|  status = ares_dns_parse_and_set_be16(buf, rr, ARES_RR_URI_PRIORITY);
  681|    853|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (681:7): [True: 0, False: 853]
  ------------------
  682|      0|    return status;
  683|      0|  }
  684|       |
  685|       |  /* WEIGHT */
  686|    853|  status = ares_dns_parse_and_set_be16(buf, rr, ARES_RR_URI_WEIGHT);
  687|    853|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (687:7): [True: 0, False: 853]
  ------------------
  688|      0|    return status;
  689|      0|  }
  690|       |
  691|       |  /* TARGET -- not in string format, rest of buffer, required to be
  692|       |   * non-zero length */
  693|    853|  remaining_len = ares_dns_rr_remaining_len(buf, orig_len, rdlength);
  694|    853|  if (remaining_len == 0) {
  ------------------
  |  Branch (694:7): [True: 2, False: 851]
  ------------------
  695|      2|    status = ARES_EBADRESP;
  696|      2|    return status;
  697|      2|  }
  698|       |
  699|       |  /* NOTE: Not in DNS string format */
  700|    851|  status = ares_buf_fetch_str_dup(buf, remaining_len, &name);
  701|    851|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (701:7): [True: 25, False: 826]
  ------------------
  702|     25|    return status;
  703|     25|  }
  704|       |
  705|    826|  if (!ares_str_isprint(name, remaining_len)) {
  ------------------
  |  Branch (705:7): [True: 0, False: 826]
  ------------------
  706|      0|    ares_free(name);
  707|      0|    return ARES_EBADRESP;
  708|      0|  }
  709|       |
  710|    826|  status = ares_dns_rr_set_str_own(rr, ARES_RR_URI_TARGET, name);
  711|    826|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (711:7): [True: 0, False: 826]
  ------------------
  712|      0|    ares_free(name);
  713|      0|    return status;
  714|      0|  }
  715|    826|  name = NULL;
  716|       |
  717|    826|  return ARES_SUCCESS;
  718|    826|}
ares_dns_parse.c:ares_dns_parse_rr_caa:
  722|    638|{
  723|    638|  unsigned char *data     = NULL;
  724|    638|  size_t         data_len = 0;
  725|    638|  ares_status_t  status;
  726|    638|  size_t         orig_len = ares_buf_len(buf);
  727|       |
  728|       |  /* CRITICAL */
  729|    638|  status = ares_dns_parse_and_set_u8(buf, rr, ARES_RR_CAA_CRITICAL);
  730|    638|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (730:7): [True: 0, False: 638]
  ------------------
  731|      0|    return status;
  732|      0|  }
  733|       |
  734|       |  /* Tag */
  735|    638|  status = ares_dns_parse_and_set_dns_str(
  736|    638|    buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), rr,
  737|    638|    ARES_RR_CAA_TAG, ARES_FALSE);
  738|    638|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (738:7): [True: 11, False: 627]
  ------------------
  739|     11|    return status;
  740|     11|  }
  741|       |
  742|       |  /* Value - binary! (remaining buffer */
  743|    627|  data_len = ares_dns_rr_remaining_len(buf, orig_len, rdlength);
  744|    627|  if (data_len == 0) {
  ------------------
  |  Branch (744:7): [True: 0, False: 627]
  ------------------
  745|      0|    status = ARES_EBADRESP;
  746|      0|    return status;
  747|      0|  }
  748|    627|  status = ares_buf_fetch_bytes_dup(buf, data_len, ARES_TRUE, &data);
  749|    627|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (749:7): [True: 0, False: 627]
  ------------------
  750|      0|    return status;
  751|      0|  }
  752|       |
  753|    627|  status = ares_dns_rr_set_bin_own(rr, ARES_RR_CAA_VALUE, data, data_len);
  754|    627|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (754:7): [True: 0, False: 627]
  ------------------
  755|      0|    ares_free(data);
  756|      0|    return status;
  757|      0|  }
  758|    627|  data = NULL;
  759|       |
  760|    627|  return ARES_SUCCESS;
  761|    627|}
ares_dns_parse.c:ares_dns_parse_rr_raw_rr:
  767|  36.3k|{
  768|  36.3k|  ares_status_t  status;
  769|  36.3k|  unsigned char *bytes = NULL;
  770|       |
  771|       |  /* Can't fail */
  772|  36.3k|  status = ares_dns_rr_set_u16(rr, ARES_RR_RAW_RR_TYPE, raw_type);
  773|  36.3k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (773:7): [True: 0, False: 36.3k]
  ------------------
  774|      0|    return status;
  775|      0|  }
  776|       |
  777|  36.3k|  if (rdlength == 0) {
  ------------------
  |  Branch (777:7): [True: 32.9k, False: 3.32k]
  ------------------
  778|  32.9k|    return ARES_SUCCESS;
  779|  32.9k|  }
  780|       |
  781|  3.32k|  status = ares_buf_fetch_bytes_dup(buf, rdlength, ARES_FALSE, &bytes);
  782|  3.32k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (782:7): [True: 0, False: 3.32k]
  ------------------
  783|      0|    return status;
  784|      0|  }
  785|       |
  786|  3.32k|  status = ares_dns_rr_set_bin_own(rr, ARES_RR_RAW_RR_DATA, bytes, rdlength);
  787|  3.32k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (787:7): [True: 0, False: 3.32k]
  ------------------
  788|      0|    ares_free(bytes);
  789|      0|    return status;
  790|      0|  }
  791|       |
  792|  3.32k|  return ARES_SUCCESS;
  793|  3.32k|}

ares_dns_record_create:
   56|  3.36k|{
   57|  3.36k|  if (dnsrec == NULL) {
  ------------------
  |  Branch (57:7): [True: 0, False: 3.36k]
  ------------------
   58|      0|    return ARES_EFORMERR;
   59|      0|  }
   60|       |
   61|  3.36k|  *dnsrec = NULL;
   62|       |
   63|  3.36k|  if (!ares_dns_opcode_isvalid(opcode) || !ares_dns_rcode_isvalid(rcode) ||
  ------------------
  |  Branch (63:7): [True: 2, False: 3.36k]
  |  Branch (63:43): [True: 0, False: 3.36k]
  ------------------
   64|  3.36k|      !ares_dns_flags_arevalid(flags)) {
  ------------------
  |  Branch (64:7): [True: 0, False: 3.36k]
  ------------------
   65|      2|    return ARES_EFORMERR;
   66|      2|  }
   67|       |
   68|  3.36k|  *dnsrec = ares_malloc_zero(sizeof(**dnsrec));
   69|  3.36k|  if (*dnsrec == NULL) {
  ------------------
  |  Branch (69:7): [True: 0, False: 3.36k]
  ------------------
   70|      0|    return ARES_ENOMEM;
   71|      0|  }
   72|       |
   73|  3.36k|  (*dnsrec)->id     = id;
   74|  3.36k|  (*dnsrec)->flags  = flags;
   75|  3.36k|  (*dnsrec)->opcode = opcode;
   76|  3.36k|  (*dnsrec)->rcode  = rcode;
   77|  3.36k|  (*dnsrec)->qd = ares_array_create(sizeof(ares_dns_qd_t), ares_dns_qd_free_cb);
   78|  3.36k|  (*dnsrec)->an = ares_array_create(sizeof(ares_dns_rr_t), ares_dns_rr_free_cb);
   79|  3.36k|  (*dnsrec)->ns = ares_array_create(sizeof(ares_dns_rr_t), ares_dns_rr_free_cb);
   80|  3.36k|  (*dnsrec)->ar = ares_array_create(sizeof(ares_dns_rr_t), ares_dns_rr_free_cb);
   81|       |
   82|  3.36k|  if ((*dnsrec)->qd == NULL || (*dnsrec)->an == NULL || (*dnsrec)->ns == NULL ||
  ------------------
  |  Branch (82:7): [True: 0, False: 3.36k]
  |  Branch (82:32): [True: 0, False: 3.36k]
  |  Branch (82:57): [True: 0, False: 3.36k]
  ------------------
   83|  3.36k|      (*dnsrec)->ar == NULL) {
  ------------------
  |  Branch (83:7): [True: 0, False: 3.36k]
  ------------------
   84|      0|    ares_dns_record_destroy(*dnsrec);
   85|      0|    *dnsrec = NULL;
   86|      0|    return ARES_ENOMEM;
   87|      0|  }
   88|       |
   89|  3.36k|  return ARES_SUCCESS;
   90|  3.36k|}
ares_dns_record_get_id:
   93|  1.82k|{
   94|  1.82k|  if (dnsrec == NULL) {
  ------------------
  |  Branch (94:7): [True: 0, False: 1.82k]
  ------------------
   95|      0|    return 0;
   96|      0|  }
   97|  1.82k|  return dnsrec->id;
   98|  1.82k|}
ares_dns_record_get_flags:
  110|  1.82k|{
  111|  1.82k|  if (dnsrec == NULL) {
  ------------------
  |  Branch (111:7): [True: 0, False: 1.82k]
  ------------------
  112|      0|    return 0;
  113|      0|  }
  114|  1.82k|  return dnsrec->flags;
  115|  1.82k|}
ares_dns_record_get_opcode:
  118|  1.82k|{
  119|  1.82k|  if (dnsrec == NULL) {
  ------------------
  |  Branch (119:7): [True: 0, False: 1.82k]
  ------------------
  120|      0|    return 0;
  121|      0|  }
  122|  1.82k|  return dnsrec->opcode;
  123|  1.82k|}
ares_dns_record_get_rcode:
  126|  1.82k|{
  127|  1.82k|  if (dnsrec == NULL) {
  ------------------
  |  Branch (127:7): [True: 0, False: 1.82k]
  ------------------
  128|      0|    return 0;
  129|      0|  }
  130|  1.82k|  return dnsrec->rcode;
  131|  1.82k|}
ares_dns_record_destroy:
  224|  5.01k|{
  225|  5.01k|  if (dnsrec == NULL) {
  ------------------
  |  Branch (225:7): [True: 1.65k, False: 3.36k]
  ------------------
  226|  1.65k|    return;
  227|  1.65k|  }
  228|       |
  229|       |  /* Free questions */
  230|  3.36k|  ares_array_destroy(dnsrec->qd);
  231|       |
  232|       |  /* Free answers */
  233|  3.36k|  ares_array_destroy(dnsrec->an);
  234|       |
  235|       |  /* Free authority */
  236|  3.36k|  ares_array_destroy(dnsrec->ns);
  237|       |
  238|       |  /* Free additional */
  239|  3.36k|  ares_array_destroy(dnsrec->ar);
  240|       |
  241|  3.36k|  ares_free(dnsrec);
  242|  3.36k|}
ares_dns_record_query_cnt:
  245|  10.7k|{
  246|  10.7k|  if (dnsrec == NULL) {
  ------------------
  |  Branch (246:7): [True: 0, False: 10.7k]
  ------------------
  247|      0|    return 0;
  248|      0|  }
  249|  10.7k|  return ares_array_len(dnsrec->qd);
  250|  10.7k|}
ares_dns_record_query_add:
  256|  3.19k|{
  257|  3.19k|  size_t         idx;
  258|  3.19k|  ares_dns_qd_t *qd;
  259|  3.19k|  ares_status_t  status;
  260|       |
  261|  3.19k|  if (dnsrec == NULL || name == NULL ||
  ------------------
  |  Branch (261:7): [True: 0, False: 3.19k]
  |  Branch (261:25): [True: 0, False: 3.19k]
  ------------------
  262|  3.19k|      !ares_dns_rec_type_isvalid(qtype, ARES_TRUE) ||
  ------------------
  |  Branch (262:7): [True: 0, False: 3.19k]
  ------------------
  263|  3.19k|      !ares_dns_class_isvalid(qclass, qtype, ARES_TRUE)) {
  ------------------
  |  Branch (263:7): [True: 25, False: 3.16k]
  ------------------
  264|     25|    return ARES_EFORMERR;
  265|     25|  }
  266|       |
  267|  3.16k|  idx    = ares_array_len(dnsrec->qd);
  268|  3.16k|  status = ares_array_insert_last((void **)&qd, dnsrec->qd);
  269|  3.16k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (269:7): [True: 0, False: 3.16k]
  ------------------
  270|      0|    return status;
  271|      0|  }
  272|       |
  273|  3.16k|  qd->name = ares_strdup(name);
  274|  3.16k|  if (qd->name == NULL) {
  ------------------
  |  Branch (274:7): [True: 0, False: 3.16k]
  ------------------
  275|      0|    ares_array_remove_at(dnsrec->qd, idx);
  276|      0|    return ARES_ENOMEM;
  277|      0|  }
  278|  3.16k|  qd->qtype  = qtype;
  279|  3.16k|  qd->qclass = qclass;
  280|  3.16k|  return ARES_SUCCESS;
  281|  3.16k|}
ares_dns_record_query_get:
  327|  3.64k|{
  328|  3.64k|  const ares_dns_qd_t *qd;
  329|  3.64k|  if (dnsrec == NULL || idx >= ares_array_len(dnsrec->qd)) {
  ------------------
  |  Branch (329:7): [True: 0, False: 3.64k]
  |  Branch (329:25): [True: 0, False: 3.64k]
  ------------------
  330|      0|    return ARES_EFORMERR;
  331|      0|  }
  332|       |
  333|  3.64k|  qd = ares_array_at(dnsrec->qd, idx);
  334|  3.64k|  if (name != NULL) {
  ------------------
  |  Branch (334:7): [True: 3.64k, False: 0]
  ------------------
  335|  3.64k|    *name = qd->name;
  336|  3.64k|  }
  337|       |
  338|  3.64k|  if (qtype != NULL) {
  ------------------
  |  Branch (338:7): [True: 3.64k, False: 0]
  ------------------
  339|  3.64k|    *qtype = qd->qtype;
  340|  3.64k|  }
  341|       |
  342|  3.64k|  if (qclass != NULL) {
  ------------------
  |  Branch (342:7): [True: 3.64k, False: 0]
  ------------------
  343|  3.64k|    *qclass = qd->qclass;
  344|  3.64k|  }
  345|       |
  346|  3.64k|  return ARES_SUCCESS;
  347|  3.64k|}
ares_dns_record_rr_cnt:
  351|   105k|{
  352|   105k|  if (dnsrec == NULL || !ares_dns_section_isvalid(sect)) {
  ------------------
  |  Branch (352:7): [True: 0, False: 105k]
  |  Branch (352:25): [True: 0, False: 105k]
  ------------------
  353|      0|    return 0;
  354|      0|  }
  355|       |
  356|   105k|  switch (sect) {
  ------------------
  |  Branch (356:11): [True: 105k, False: 0]
  ------------------
  357|  27.4k|    case ARES_SECTION_ANSWER:
  ------------------
  |  Branch (357:5): [True: 27.4k, False: 77.5k]
  ------------------
  358|  27.4k|      return ares_array_len(dnsrec->an);
  359|  27.1k|    case ARES_SECTION_AUTHORITY:
  ------------------
  |  Branch (359:5): [True: 27.1k, False: 77.9k]
  ------------------
  360|  27.1k|      return ares_array_len(dnsrec->ns);
  361|  50.4k|    case ARES_SECTION_ADDITIONAL:
  ------------------
  |  Branch (361:5): [True: 50.4k, False: 54.5k]
  ------------------
  362|  50.4k|      return ares_array_len(dnsrec->ar);
  363|   105k|  }
  364|       |
  365|      0|  return 0; /* LCOV_EXCL_LINE: DefensiveCoding */
  366|   105k|}
ares_dns_record_rr_prealloc:
  370|  2.90k|{
  371|  2.90k|  ares_array_t *arr = NULL;
  372|       |
  373|  2.90k|  if (dnsrec == NULL || !ares_dns_section_isvalid(sect)) {
  ------------------
  |  Branch (373:7): [True: 0, False: 2.90k]
  |  Branch (373:25): [True: 0, False: 2.90k]
  ------------------
  374|      0|    return ARES_EFORMERR;
  375|      0|  }
  376|       |
  377|  2.90k|  switch (sect) {
  ------------------
  |  Branch (377:11): [True: 2.90k, False: 0]
  ------------------
  378|  1.34k|    case ARES_SECTION_ANSWER:
  ------------------
  |  Branch (378:5): [True: 1.34k, False: 1.55k]
  ------------------
  379|  1.34k|      arr = dnsrec->an;
  380|  1.34k|      break;
  381|    828|    case ARES_SECTION_AUTHORITY:
  ------------------
  |  Branch (381:5): [True: 828, False: 2.07k]
  ------------------
  382|    828|      arr = dnsrec->ns;
  383|    828|      break;
  384|    729|    case ARES_SECTION_ADDITIONAL:
  ------------------
  |  Branch (384:5): [True: 729, False: 2.17k]
  ------------------
  385|    729|      arr = dnsrec->ar;
  386|    729|      break;
  387|  2.90k|  }
  388|       |
  389|  2.90k|  if (cnt < ares_array_len(arr)) {
  ------------------
  |  Branch (389:7): [True: 0, False: 2.90k]
  ------------------
  390|      0|    return ARES_EFORMERR;
  391|      0|  }
  392|       |
  393|  2.90k|  return ares_array_set_size(arr, cnt);
  394|  2.90k|}
ares_dns_record_rr_add:
  401|  64.2k|{
  402|  64.2k|  ares_dns_rr_t *rr  = NULL;
  403|  64.2k|  ares_array_t  *arr = NULL;
  404|  64.2k|  ares_status_t  status;
  405|  64.2k|  size_t         idx;
  406|       |
  407|  64.2k|  if (dnsrec == NULL || name == NULL || rr_out == NULL ||
  ------------------
  |  Branch (407:7): [True: 0, False: 64.2k]
  |  Branch (407:25): [True: 0, False: 64.2k]
  |  Branch (407:41): [True: 0, False: 64.2k]
  ------------------
  408|  64.2k|      !ares_dns_section_isvalid(sect) ||
  ------------------
  |  Branch (408:7): [True: 0, False: 64.2k]
  ------------------
  409|  64.2k|      !ares_dns_rec_type_isvalid(type, ARES_FALSE) ||
  ------------------
  |  Branch (409:7): [True: 0, False: 64.2k]
  ------------------
  410|  64.2k|      !ares_dns_class_isvalid(rclass, type, ARES_FALSE)) {
  ------------------
  |  Branch (410:7): [True: 4, False: 64.2k]
  ------------------
  411|      4|    return ARES_EFORMERR;
  412|      4|  }
  413|       |
  414|  64.2k|  *rr_out = NULL;
  415|       |
  416|  64.2k|  switch (sect) {
  ------------------
  |  Branch (416:11): [True: 64.2k, False: 0]
  ------------------
  417|  16.9k|    case ARES_SECTION_ANSWER:
  ------------------
  |  Branch (417:5): [True: 16.9k, False: 47.3k]
  ------------------
  418|  16.9k|      arr = dnsrec->an;
  419|  16.9k|      break;
  420|  17.5k|    case ARES_SECTION_AUTHORITY:
  ------------------
  |  Branch (420:5): [True: 17.5k, False: 46.6k]
  ------------------
  421|  17.5k|      arr = dnsrec->ns;
  422|  17.5k|      break;
  423|  29.7k|    case ARES_SECTION_ADDITIONAL:
  ------------------
  |  Branch (423:5): [True: 29.7k, False: 34.4k]
  ------------------
  424|  29.7k|      arr = dnsrec->ar;
  425|  29.7k|      break;
  426|  64.2k|  }
  427|       |
  428|  64.2k|  idx    = ares_array_len(arr);
  429|  64.2k|  status = ares_array_insert_last((void **)&rr, arr);
  430|  64.2k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (430:7): [True: 0, False: 64.2k]
  ------------------
  431|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  432|      0|  }
  433|       |
  434|  64.2k|  rr->name = ares_strdup(name);
  435|  64.2k|  if (rr->name == NULL) {
  ------------------
  |  Branch (435:7): [True: 0, False: 64.2k]
  ------------------
  436|      0|    ares_array_remove_at(arr, idx);
  437|      0|    return ARES_ENOMEM;
  438|      0|  }
  439|       |
  440|  64.2k|  rr->parent = dnsrec;
  441|  64.2k|  rr->type   = type;
  442|  64.2k|  rr->rclass = rclass;
  443|  64.2k|  rr->ttl    = ttl;
  444|       |
  445|  64.2k|  *rr_out = rr;
  446|       |
  447|  64.2k|  return ARES_SUCCESS;
  448|  64.2k|}
ares_dns_record_rr_get:
  476|  84.9k|{
  477|  84.9k|  ares_array_t *arr = NULL;
  478|       |
  479|  84.9k|  if (dnsrec == NULL || !ares_dns_section_isvalid(sect)) {
  ------------------
  |  Branch (479:7): [True: 0, False: 84.9k]
  |  Branch (479:25): [True: 0, False: 84.9k]
  ------------------
  480|      0|    return NULL;
  481|      0|  }
  482|       |
  483|  84.9k|  switch (sect) {
  ------------------
  |  Branch (483:11): [True: 84.9k, False: 0]
  ------------------
  484|  20.5k|    case ARES_SECTION_ANSWER:
  ------------------
  |  Branch (484:5): [True: 20.5k, False: 64.3k]
  ------------------
  485|  20.5k|      arr = dnsrec->an;
  486|  20.5k|      break;
  487|  20.4k|    case ARES_SECTION_AUTHORITY:
  ------------------
  |  Branch (487:5): [True: 20.4k, False: 64.4k]
  ------------------
  488|  20.4k|      arr = dnsrec->ns;
  489|  20.4k|      break;
  490|  43.8k|    case ARES_SECTION_ADDITIONAL:
  ------------------
  |  Branch (490:5): [True: 43.8k, False: 41.0k]
  ------------------
  491|  43.8k|      arr = dnsrec->ar;
  492|  43.8k|      break;
  493|  84.9k|  }
  494|       |
  495|  84.9k|  return ares_array_at(arr, idx);
  496|  84.9k|}
ares_dns_record_rr_get_const:
  501|  28.9k|{
  502|  28.9k|  return ares_dns_record_rr_get((void *)((size_t)dnsrec), sect, idx);
  503|  28.9k|}
ares_dns_rr_get_name:
  506|  71.9k|{
  507|  71.9k|  if (rr == NULL) {
  ------------------
  |  Branch (507:7): [True: 0, False: 71.9k]
  ------------------
  508|      0|    return NULL;
  509|      0|  }
  510|  71.9k|  return rr->name;
  511|  71.9k|}
ares_dns_rr_get_type:
  514|   140k|{
  515|   140k|  if (rr == NULL) {
  ------------------
  |  Branch (515:7): [True: 0, False: 140k]
  ------------------
  516|      0|    return 0;
  517|      0|  }
  518|   140k|  return rr->type;
  519|   140k|}
ares_dns_rr_get_class:
  522|  71.7k|{
  523|  71.7k|  if (rr == NULL) {
  ------------------
  |  Branch (523:7): [True: 0, False: 71.7k]
  ------------------
  524|      0|    return 0;
  525|      0|  }
  526|  71.7k|  return rr->rclass;
  527|  71.7k|}
ares_dns_rr_get_ttl:
  530|  71.7k|{
  531|  71.7k|  if (rr == NULL) {
  ------------------
  |  Branch (531:7): [True: 0, False: 71.7k]
  ------------------
  532|      0|    return 0;
  533|      0|  }
  534|  71.7k|  return rr->ttl;
  535|  71.7k|}
ares_dns_rr_get_addr:
  759|    873|{
  760|    873|  const struct in_addr *addr;
  761|       |
  762|    873|  if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_INADDR) {
  ------------------
  |  Branch (762:7): [True: 0, False: 873]
  ------------------
  763|      0|    return NULL;
  764|      0|  }
  765|       |
  766|    873|  addr = ares_dns_rr_data_ptr_const(dns_rr, key, NULL);
  767|    873|  if (addr == NULL) {
  ------------------
  |  Branch (767:7): [True: 0, False: 873]
  ------------------
  768|      0|    return NULL;
  769|      0|  }
  770|       |
  771|    873|  return addr;
  772|    873|}
ares_dns_rr_get_addr6:
  776|  7.10k|{
  777|  7.10k|  const struct ares_in6_addr *addr;
  778|       |
  779|  7.10k|  if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_INADDR6) {
  ------------------
  |  Branch (779:7): [True: 0, False: 7.10k]
  ------------------
  780|      0|    return NULL;
  781|      0|  }
  782|       |
  783|  7.10k|  addr = ares_dns_rr_data_ptr_const(dns_rr, key, NULL);
  784|  7.10k|  if (addr == NULL) {
  ------------------
  |  Branch (784:7): [True: 0, False: 7.10k]
  ------------------
  785|      0|    return NULL;
  786|      0|  }
  787|       |
  788|  7.10k|  return addr;
  789|  7.10k|}
ares_dns_rr_get_u8:
  793|  13.1k|{
  794|  13.1k|  const unsigned char *u8;
  795|       |
  796|  13.1k|  if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_U8) {
  ------------------
  |  Branch (796:7): [True: 0, False: 13.1k]
  ------------------
  797|      0|    return 0;
  798|      0|  }
  799|       |
  800|  13.1k|  u8 = ares_dns_rr_data_ptr_const(dns_rr, key, NULL);
  801|  13.1k|  if (u8 == NULL) {
  ------------------
  |  Branch (801:7): [True: 0, False: 13.1k]
  ------------------
  802|      0|    return 0;
  803|      0|  }
  804|       |
  805|  13.1k|  return *u8;
  806|  13.1k|}
ares_dns_rr_get_u16:
  810|  62.0k|{
  811|  62.0k|  const unsigned short *u16;
  812|       |
  813|  62.0k|  if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_U16) {
  ------------------
  |  Branch (813:7): [True: 0, False: 62.0k]
  ------------------
  814|      0|    return 0;
  815|      0|  }
  816|       |
  817|  62.0k|  u16 = ares_dns_rr_data_ptr_const(dns_rr, key, NULL);
  818|  62.0k|  if (u16 == NULL) {
  ------------------
  |  Branch (818:7): [True: 0, False: 62.0k]
  ------------------
  819|      0|    return 0;
  820|      0|  }
  821|       |
  822|  62.0k|  return *u16;
  823|  62.0k|}
ares_dns_rr_get_u32:
  827|  13.0k|{
  828|  13.0k|  const unsigned int *u32;
  829|       |
  830|  13.0k|  if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_U32) {
  ------------------
  |  Branch (830:7): [True: 0, False: 13.0k]
  ------------------
  831|      0|    return 0;
  832|      0|  }
  833|       |
  834|  13.0k|  u32 = ares_dns_rr_data_ptr_const(dns_rr, key, NULL);
  835|  13.0k|  if (u32 == NULL) {
  ------------------
  |  Branch (835:7): [True: 0, False: 13.0k]
  ------------------
  836|      0|    return 0;
  837|      0|  }
  838|       |
  839|  13.0k|  return *u32;
  840|  13.0k|}
ares_dns_rr_get_bin:
  844|  4.21k|{
  845|  4.21k|  unsigned char * const *bin     = NULL;
  846|  4.21k|  size_t const          *bin_len = NULL;
  847|       |
  848|  4.21k|  if ((ares_dns_rr_key_datatype(key) != ARES_DATATYPE_BIN &&
  ------------------
  |  Branch (848:8): [True: 1.06k, False: 3.14k]
  ------------------
  849|  1.06k|       ares_dns_rr_key_datatype(key) != ARES_DATATYPE_BINP &&
  ------------------
  |  Branch (849:8): [True: 0, False: 1.06k]
  ------------------
  850|      0|       ares_dns_rr_key_datatype(key) != ARES_DATATYPE_ABINP) ||
  ------------------
  |  Branch (850:8): [True: 0, False: 0]
  ------------------
  851|  4.21k|      len == NULL) {
  ------------------
  |  Branch (851:7): [True: 0, False: 4.21k]
  ------------------
  852|      0|    return NULL;
  853|      0|  }
  854|       |
  855|       |  /* Array of strings, return concatenated version */
  856|  4.21k|  if (ares_dns_rr_key_datatype(key) == ARES_DATATYPE_ABINP) {
  ------------------
  |  Branch (856:7): [True: 0, False: 4.21k]
  ------------------
  857|      0|    ares_dns_multistring_t * const *strs =
  858|      0|      ares_dns_rr_data_ptr_const(dns_rr, key, NULL);
  859|       |
  860|      0|    if (strs == NULL) {
  ------------------
  |  Branch (860:9): [True: 0, False: 0]
  ------------------
  861|      0|      return NULL;
  862|      0|    }
  863|       |
  864|      0|    return ares_dns_multistring_combined(*strs, len);
  865|      0|  }
  866|       |
  867|       |  /* Not a multi-string, just straight binary data */
  868|  4.21k|  bin = ares_dns_rr_data_ptr_const(dns_rr, key, &bin_len);
  869|  4.21k|  if (bin == NULL) {
  ------------------
  |  Branch (869:7): [True: 0, False: 4.21k]
  ------------------
  870|      0|    return NULL;
  871|      0|  }
  872|       |
  873|       |  /* Shouldn't be possible */
  874|  4.21k|  if (bin_len == NULL) {
  ------------------
  |  Branch (874:7): [True: 0, False: 4.21k]
  ------------------
  875|      0|    return NULL;
  876|      0|  }
  877|  4.21k|  *len = *bin_len;
  878|       |
  879|  4.21k|  return *bin;
  880|  4.21k|}
ares_dns_rr_get_abin_cnt:
  884|   139k|{
  885|   139k|  ares_dns_multistring_t * const *strs;
  886|       |
  887|   139k|  if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_ABINP) {
  ------------------
  |  Branch (887:7): [True: 0, False: 139k]
  ------------------
  888|      0|    return 0;
  889|      0|  }
  890|       |
  891|   139k|  strs = ares_dns_rr_data_ptr_const(dns_rr, key, NULL);
  892|   139k|  if (strs == NULL) {
  ------------------
  |  Branch (892:7): [True: 0, False: 139k]
  ------------------
  893|      0|    return 0;
  894|      0|  }
  895|       |
  896|   139k|  return ares_dns_multistring_cnt(*strs);
  897|   139k|}
ares_dns_rr_get_abin:
  902|   220k|{
  903|   220k|  ares_dns_multistring_t * const *strs;
  904|       |
  905|   220k|  if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_ABINP) {
  ------------------
  |  Branch (905:7): [True: 0, False: 220k]
  ------------------
  906|      0|    return NULL;
  907|      0|  }
  908|       |
  909|   220k|  strs = ares_dns_rr_data_ptr_const(dns_rr, key, NULL);
  910|   220k|  if (strs == NULL) {
  ------------------
  |  Branch (910:7): [True: 0, False: 220k]
  ------------------
  911|      0|    return NULL;
  912|      0|  }
  913|       |
  914|   220k|  return ares_dns_multistring_get(*strs, idx, len);
  915|   220k|}
ares_dns_rr_get_str:
  983|  28.8k|{
  984|  28.8k|  char * const *str;
  985|       |
  986|  28.8k|  if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_STR &&
  ------------------
  |  Branch (986:7): [True: 20.3k, False: 8.54k]
  ------------------
  987|  20.3k|      ares_dns_rr_key_datatype(key) != ARES_DATATYPE_NAME) {
  ------------------
  |  Branch (987:7): [True: 0, False: 20.3k]
  ------------------
  988|      0|    return NULL;
  989|      0|  }
  990|       |
  991|  28.8k|  str = ares_dns_rr_data_ptr_const(dns_rr, key, NULL);
  992|  28.8k|  if (str == NULL) {
  ------------------
  |  Branch (992:7): [True: 0, False: 28.8k]
  ------------------
  993|      0|    return NULL;
  994|      0|  }
  995|       |
  996|  28.8k|  return *str;
  997|  28.8k|}
ares_dns_rr_get_opt_cnt:
 1001|  7.69k|{
 1002|  7.69k|  ares_array_t * const *opts;
 1003|       |
 1004|  7.69k|  if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_OPT) {
  ------------------
  |  Branch (1004:7): [True: 0, False: 7.69k]
  ------------------
 1005|      0|    return 0;
 1006|      0|  }
 1007|       |
 1008|  7.69k|  opts = ares_dns_rr_data_ptr_const(dns_rr, key, NULL);
 1009|  7.69k|  if (opts == NULL || *opts == NULL) {
  ------------------
  |  Branch (1009:7): [True: 0, False: 7.69k]
  |  Branch (1009:23): [True: 2.94k, False: 4.74k]
  ------------------
 1010|  2.94k|    return 0;
 1011|  2.94k|  }
 1012|       |
 1013|  4.74k|  return ares_array_len(*opts);
 1014|  7.69k|}
ares_dns_rr_get_opt:
 1019|  3.97k|{
 1020|  3.97k|  ares_array_t * const    *opts;
 1021|  3.97k|  const ares_dns_optval_t *opt;
 1022|       |
 1023|  3.97k|  if (val) {
  ------------------
  |  Branch (1023:7): [True: 3.97k, False: 0]
  ------------------
 1024|  3.97k|    *val = NULL;
 1025|  3.97k|  }
 1026|  3.97k|  if (val_len) {
  ------------------
  |  Branch (1026:7): [True: 3.97k, False: 0]
  ------------------
 1027|  3.97k|    *val_len = 0;
 1028|  3.97k|  }
 1029|       |
 1030|  3.97k|  if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_OPT) {
  ------------------
  |  Branch (1030:7): [True: 0, False: 3.97k]
  ------------------
 1031|      0|    return 65535;
 1032|      0|  }
 1033|       |
 1034|  3.97k|  opts = ares_dns_rr_data_ptr_const(dns_rr, key, NULL);
 1035|  3.97k|  if (opts == NULL || *opts == NULL) {
  ------------------
  |  Branch (1035:7): [True: 0, False: 3.97k]
  |  Branch (1035:23): [True: 0, False: 3.97k]
  ------------------
 1036|      0|    return 65535;
 1037|      0|  }
 1038|       |
 1039|  3.97k|  opt = ares_array_at(*opts, idx);
 1040|  3.97k|  if (opt == NULL) {
  ------------------
  |  Branch (1040:7): [True: 0, False: 3.97k]
  ------------------
 1041|      0|    return 65535;
 1042|      0|  }
 1043|       |
 1044|  3.97k|  if (val) {
  ------------------
  |  Branch (1044:7): [True: 3.97k, False: 0]
  ------------------
 1045|  3.97k|    *val = opt->val;
 1046|  3.97k|  }
 1047|  3.97k|  if (val_len) {
  ------------------
  |  Branch (1047:7): [True: 3.97k, False: 0]
  ------------------
 1048|  3.97k|    *val_len = opt->val_len;
 1049|  3.97k|  }
 1050|       |
 1051|  3.97k|  return opt->opt;
 1052|  3.97k|}
ares_dns_rr_set_addr:
 1105|    636|{
 1106|    636|  struct in_addr *a;
 1107|       |
 1108|    636|  if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_INADDR || addr == NULL) {
  ------------------
  |  Branch (1108:7): [True: 0, False: 636]
  |  Branch (1108:64): [True: 0, False: 636]
  ------------------
 1109|      0|    return ARES_EFORMERR;
 1110|      0|  }
 1111|       |
 1112|    636|  a = ares_dns_rr_data_ptr(dns_rr, key, NULL);
 1113|    636|  if (a == NULL) {
  ------------------
  |  Branch (1113:7): [True: 0, False: 636]
  ------------------
 1114|      0|    return ARES_EFORMERR;
 1115|      0|  }
 1116|       |
 1117|    636|  memcpy(a, addr, sizeof(*a));
 1118|    636|  return ARES_SUCCESS;
 1119|    636|}
ares_dns_rr_set_addr6:
 1124|  6.65k|{
 1125|  6.65k|  struct ares_in6_addr *a;
 1126|       |
 1127|  6.65k|  if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_INADDR6 || addr == NULL) {
  ------------------
  |  Branch (1127:7): [True: 0, False: 6.65k]
  |  Branch (1127:65): [True: 0, False: 6.65k]
  ------------------
 1128|      0|    return ARES_EFORMERR;
 1129|      0|  }
 1130|       |
 1131|  6.65k|  a = ares_dns_rr_data_ptr(dns_rr, key, NULL);
 1132|  6.65k|  if (a == NULL) {
  ------------------
  |  Branch (1132:7): [True: 0, False: 6.65k]
  ------------------
 1133|      0|    return ARES_EFORMERR;
 1134|      0|  }
 1135|       |
 1136|  6.65k|  memcpy(a, addr, sizeof(*a));
 1137|  6.65k|  return ARES_SUCCESS;
 1138|  6.65k|}
ares_dns_rr_set_u8:
 1142|  8.38k|{
 1143|  8.38k|  unsigned char *u8;
 1144|       |
 1145|  8.38k|  if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_U8) {
  ------------------
  |  Branch (1145:7): [True: 0, False: 8.38k]
  ------------------
 1146|      0|    return ARES_EFORMERR;
 1147|      0|  }
 1148|       |
 1149|  8.38k|  u8 = ares_dns_rr_data_ptr(dns_rr, key, NULL);
 1150|  8.38k|  if (u8 == NULL) {
  ------------------
  |  Branch (1150:7): [True: 0, False: 8.38k]
  ------------------
 1151|      0|    return ARES_EFORMERR;
 1152|      0|  }
 1153|       |
 1154|  8.38k|  *u8 = val;
 1155|  8.38k|  return ARES_SUCCESS;
 1156|  8.38k|}
ares_dns_rr_set_u16:
 1160|  56.3k|{
 1161|  56.3k|  unsigned short *u16;
 1162|       |
 1163|  56.3k|  if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_U16) {
  ------------------
  |  Branch (1163:7): [True: 0, False: 56.3k]
  ------------------
 1164|      0|    return ARES_EFORMERR;
 1165|      0|  }
 1166|       |
 1167|  56.3k|  u16 = ares_dns_rr_data_ptr(dns_rr, key, NULL);
 1168|  56.3k|  if (u16 == NULL) {
  ------------------
  |  Branch (1168:7): [True: 0, False: 56.3k]
  ------------------
 1169|      0|    return ARES_EFORMERR;
 1170|      0|  }
 1171|       |
 1172|  56.3k|  *u16 = val;
 1173|  56.3k|  return ARES_SUCCESS;
 1174|  56.3k|}
ares_dns_rr_set_u32:
 1178|  9.68k|{
 1179|  9.68k|  unsigned int *u32;
 1180|       |
 1181|  9.68k|  if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_U32) {
  ------------------
  |  Branch (1181:7): [True: 0, False: 9.68k]
  ------------------
 1182|      0|    return ARES_EFORMERR;
 1183|      0|  }
 1184|       |
 1185|  9.68k|  u32 = ares_dns_rr_data_ptr(dns_rr, key, NULL);
 1186|  9.68k|  if (u32 == NULL) {
  ------------------
  |  Branch (1186:7): [True: 0, False: 9.68k]
  ------------------
 1187|      0|    return ARES_EFORMERR;
 1188|      0|  }
 1189|       |
 1190|  9.68k|  *u32 = val;
 1191|  9.68k|  return ARES_SUCCESS;
 1192|  9.68k|}
ares_dns_rr_set_bin_own:
 1197|  5.99k|{
 1198|  5.99k|  unsigned char **bin;
 1199|  5.99k|  size_t         *bin_len = NULL;
 1200|       |
 1201|  5.99k|  if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_BIN &&
  ------------------
  |  Branch (1201:7): [True: 627, False: 5.36k]
  ------------------
 1202|    627|      ares_dns_rr_key_datatype(key) != ARES_DATATYPE_BINP &&
  ------------------
  |  Branch (1202:7): [True: 0, False: 627]
  ------------------
 1203|      0|      ares_dns_rr_key_datatype(key) != ARES_DATATYPE_ABINP) {
  ------------------
  |  Branch (1203:7): [True: 0, False: 0]
  ------------------
 1204|      0|    return ARES_EFORMERR;
 1205|      0|  }
 1206|       |
 1207|  5.99k|  if (ares_dns_rr_key_datatype(key) == ARES_DATATYPE_ABINP) {
  ------------------
  |  Branch (1207:7): [True: 0, False: 5.99k]
  ------------------
 1208|      0|    ares_dns_multistring_t **strs = ares_dns_rr_data_ptr(dns_rr, key, NULL);
 1209|      0|    if (strs == NULL) {
  ------------------
  |  Branch (1209:9): [True: 0, False: 0]
  ------------------
 1210|      0|      return ARES_EFORMERR;
 1211|      0|    }
 1212|       |
 1213|      0|    if (*strs == NULL) {
  ------------------
  |  Branch (1213:9): [True: 0, False: 0]
  ------------------
 1214|      0|      *strs = ares_dns_multistring_create();
 1215|      0|      if (*strs == NULL) {
  ------------------
  |  Branch (1215:11): [True: 0, False: 0]
  ------------------
 1216|      0|        return ARES_ENOMEM;
 1217|      0|      }
 1218|      0|    }
 1219|       |
 1220|       |    /* Clear all existing entries as this is an override */
 1221|      0|    ares_dns_multistring_clear(*strs);
 1222|       |
 1223|      0|    return ares_dns_multistring_add_own(*strs, val, len);
 1224|      0|  }
 1225|       |
 1226|  5.99k|  bin = ares_dns_rr_data_ptr(dns_rr, key, &bin_len);
 1227|  5.99k|  if (bin == NULL || bin_len == NULL) {
  ------------------
  |  Branch (1227:7): [True: 0, False: 5.99k]
  |  Branch (1227:22): [True: 0, False: 5.99k]
  ------------------
 1228|      0|    return ARES_EFORMERR;
 1229|      0|  }
 1230|       |
 1231|  5.99k|  if (*bin) {
  ------------------
  |  Branch (1231:7): [True: 0, False: 5.99k]
  ------------------
 1232|      0|    ares_free(*bin);
 1233|      0|  }
 1234|  5.99k|  *bin     = val;
 1235|  5.99k|  *bin_len = len;
 1236|       |
 1237|  5.99k|  return ARES_SUCCESS;
 1238|  5.99k|}
ares_dns_rr_set_str_own:
 1273|  21.3k|{
 1274|  21.3k|  char **str;
 1275|       |
 1276|  21.3k|  if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_STR &&
  ------------------
  |  Branch (1276:7): [True: 14.7k, False: 6.53k]
  ------------------
 1277|  14.7k|      ares_dns_rr_key_datatype(key) != ARES_DATATYPE_NAME) {
  ------------------
  |  Branch (1277:7): [True: 0, False: 14.7k]
  ------------------
 1278|      0|    return ARES_EFORMERR;
 1279|      0|  }
 1280|       |
 1281|  21.3k|  str = ares_dns_rr_data_ptr(dns_rr, key, NULL);
 1282|  21.3k|  if (str == NULL) {
  ------------------
  |  Branch (1282:7): [True: 0, False: 21.3k]
  ------------------
 1283|      0|    return ARES_EFORMERR;
 1284|      0|  }
 1285|       |
 1286|  21.3k|  if (*str) {
  ------------------
  |  Branch (1286:7): [True: 0, False: 21.3k]
  ------------------
 1287|      0|    ares_free(*str);
 1288|      0|  }
 1289|  21.3k|  *str = val;
 1290|       |
 1291|  21.3k|  return ARES_SUCCESS;
 1292|  21.3k|}
ares_dns_rr_set_abin_own:
 1318|  1.20k|{
 1319|  1.20k|  ares_dns_multistring_t **strs_ptr;
 1320|       |
 1321|  1.20k|  if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_ABINP) {
  ------------------
  |  Branch (1321:7): [True: 0, False: 1.20k]
  ------------------
 1322|      0|    return ARES_EFORMERR;
 1323|      0|  }
 1324|       |
 1325|  1.20k|  strs_ptr = ares_dns_rr_data_ptr(dns_rr, key, NULL);
 1326|  1.20k|  if (strs_ptr == NULL) {
  ------------------
  |  Branch (1326:7): [True: 0, False: 1.20k]
  ------------------
 1327|      0|    return ARES_EFORMERR;
 1328|      0|  }
 1329|       |
 1330|  1.20k|  if (*strs_ptr != NULL) {
  ------------------
  |  Branch (1330:7): [True: 0, False: 1.20k]
  ------------------
 1331|      0|    ares_dns_multistring_destroy(*strs_ptr);
 1332|      0|  }
 1333|  1.20k|  *strs_ptr = strs;
 1334|       |
 1335|  1.20k|  return ARES_SUCCESS;
 1336|  1.20k|}
ares_dns_rr_set_opt_own:
 1350|  9.18k|{
 1351|  9.18k|  ares_array_t     **options;
 1352|  9.18k|  ares_dns_optval_t *optptr = NULL;
 1353|  9.18k|  size_t             idx;
 1354|  9.18k|  size_t             cnt;
 1355|  9.18k|  ares_status_t      status;
 1356|       |
 1357|  9.18k|  if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_OPT) {
  ------------------
  |  Branch (1357:7): [True: 0, False: 9.18k]
  ------------------
 1358|      0|    return ARES_EFORMERR;
 1359|      0|  }
 1360|       |
 1361|  9.18k|  options = ares_dns_rr_data_ptr(dns_rr, key, NULL);
 1362|  9.18k|  if (options == NULL) {
  ------------------
  |  Branch (1362:7): [True: 0, False: 9.18k]
  ------------------
 1363|      0|    return ARES_EFORMERR;
 1364|      0|  }
 1365|       |
 1366|  9.18k|  if (*options == NULL) {
  ------------------
  |  Branch (1366:7): [True: 1.20k, False: 7.98k]
  ------------------
 1367|  1.20k|    *options =
 1368|  1.20k|      ares_array_create(sizeof(ares_dns_optval_t), ares_dns_opt_free_cb);
 1369|  1.20k|  }
 1370|  9.18k|  if (*options == NULL) {
  ------------------
  |  Branch (1370:7): [True: 0, False: 9.18k]
  ------------------
 1371|      0|    return ARES_ENOMEM;
 1372|      0|  }
 1373|       |
 1374|  9.18k|  cnt = ares_array_len(*options);
 1375|  94.6k|  for (idx = 0; idx < cnt; idx++) {
  ------------------
  |  Branch (1375:17): [True: 89.0k, False: 5.60k]
  ------------------
 1376|  89.0k|    optptr = ares_array_at(*options, idx);
 1377|  89.0k|    if (optptr == NULL) {
  ------------------
  |  Branch (1377:9): [True: 0, False: 89.0k]
  ------------------
 1378|      0|      return ARES_EFORMERR;
 1379|      0|    }
 1380|  89.0k|    if (optptr->opt == opt) {
  ------------------
  |  Branch (1380:9): [True: 3.57k, False: 85.4k]
  ------------------
 1381|  3.57k|      break;
 1382|  3.57k|    }
 1383|  89.0k|  }
 1384|       |
 1385|       |  /* Duplicate entry, replace */
 1386|  9.18k|  if (idx != cnt && optptr != NULL) {
  ------------------
  |  Branch (1386:7): [True: 3.57k, False: 5.60k]
  |  Branch (1386:21): [True: 3.57k, False: 0]
  ------------------
 1387|  3.57k|    goto done;
 1388|  3.57k|  }
 1389|       |
 1390|  5.60k|  status = ares_array_insert_last((void **)&optptr, *options);
 1391|  5.60k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1391:7): [True: 0, False: 5.60k]
  ------------------
 1392|      0|    return status;
 1393|      0|  }
 1394|       |
 1395|  9.18k|done:
 1396|  9.18k|  ares_free(optptr->val);
 1397|  9.18k|  optptr->opt     = opt;
 1398|  9.18k|  optptr->val     = val;
 1399|  9.18k|  optptr->val_len = val_len;
 1400|       |
 1401|  9.18k|  return ARES_SUCCESS;
 1402|  5.60k|}
ares_dns_get_opt_rr_const:
 1551|     57|{
 1552|     57|  size_t i;
 1553|  12.9k|  for (i = 0; i < ares_dns_record_rr_cnt(rec, ARES_SECTION_ADDITIONAL); i++) {
  ------------------
  |  Branch (1553:15): [True: 12.9k, False: 40]
  ------------------
 1554|  12.9k|    const ares_dns_rr_t *rr =
 1555|  12.9k|      ares_dns_record_rr_get_const(rec, ARES_SECTION_ADDITIONAL, i);
 1556|       |
 1557|  12.9k|    if (ares_dns_rr_get_type(rr) == ARES_REC_TYPE_OPT) {
  ------------------
  |  Branch (1557:9): [True: 17, False: 12.9k]
  ------------------
 1558|     17|      return rr;
 1559|     17|    }
 1560|  12.9k|  }
 1561|     40|  return NULL;
 1562|     57|}
ares_dns_record.c:ares_dns_qd_free_cb:
   35|  3.16k|{
   36|  3.16k|  ares_dns_qd_t *qd = arg;
   37|  3.16k|  if (qd == NULL) {
  ------------------
  |  Branch (37:7): [True: 0, False: 3.16k]
  ------------------
   38|      0|    return;
   39|      0|  }
   40|  3.16k|  ares_free(qd->name);
   41|  3.16k|}
ares_dns_record.c:ares_dns_rr_free_cb:
   44|  64.2k|{
   45|  64.2k|  ares_dns_rr_t *rr = arg;
   46|  64.2k|  if (rr == NULL) {
  ------------------
  |  Branch (46:7): [True: 0, False: 64.2k]
  ------------------
   47|      0|    return;
   48|      0|  }
   49|  64.2k|  ares_dns_rr_free(rr);
   50|  64.2k|}
ares_dns_record.c:ares_dns_rr_free:
  134|  64.2k|{
  135|  64.2k|  ares_free(rr->name);
  136|       |
  137|  64.2k|  switch (rr->type) {
  ------------------
  |  Branch (137:11): [True: 64.2k, False: 0]
  ------------------
  138|    636|    case ARES_REC_TYPE_A:
  ------------------
  |  Branch (138:5): [True: 636, False: 63.6k]
  ------------------
  139|  7.29k|    case ARES_REC_TYPE_AAAA:
  ------------------
  |  Branch (139:5): [True: 6.65k, False: 57.5k]
  ------------------
  140|  7.29k|    case ARES_REC_TYPE_ANY:
  ------------------
  |  Branch (140:5): [True: 0, False: 64.2k]
  ------------------
  141|       |      /* Nothing to free */
  142|  7.29k|      break;
  143|       |
  144|  1.31k|    case ARES_REC_TYPE_NS:
  ------------------
  |  Branch (144:5): [True: 1.31k, False: 62.9k]
  ------------------
  145|  1.31k|      ares_free(rr->r.ns.nsdname);
  146|  1.31k|      break;
  147|       |
  148|  1.23k|    case ARES_REC_TYPE_CNAME:
  ------------------
  |  Branch (148:5): [True: 1.23k, False: 63.0k]
  ------------------
  149|  1.23k|      ares_free(rr->r.cname.cname);
  150|  1.23k|      break;
  151|       |
  152|  1.10k|    case ARES_REC_TYPE_SOA:
  ------------------
  |  Branch (152:5): [True: 1.10k, False: 63.1k]
  ------------------
  153|  1.10k|      ares_free(rr->r.soa.mname);
  154|  1.10k|      ares_free(rr->r.soa.rname);
  155|  1.10k|      break;
  156|       |
  157|    546|    case ARES_REC_TYPE_PTR:
  ------------------
  |  Branch (157:5): [True: 546, False: 63.6k]
  ------------------
  158|    546|      ares_free(rr->r.ptr.dname);
  159|    546|      break;
  160|       |
  161|  1.40k|    case ARES_REC_TYPE_HINFO:
  ------------------
  |  Branch (161:5): [True: 1.40k, False: 62.8k]
  ------------------
  162|  1.40k|      ares_free(rr->r.hinfo.cpu);
  163|  1.40k|      ares_free(rr->r.hinfo.os);
  164|  1.40k|      break;
  165|       |
  166|  3.38k|    case ARES_REC_TYPE_MX:
  ------------------
  |  Branch (166:5): [True: 3.38k, False: 60.8k]
  ------------------
  167|  3.38k|      ares_free(rr->r.mx.exchange);
  168|  3.38k|      break;
  169|       |
  170|  1.21k|    case ARES_REC_TYPE_TXT:
  ------------------
  |  Branch (170:5): [True: 1.21k, False: 63.0k]
  ------------------
  171|  1.21k|      ares_dns_multistring_destroy(rr->r.txt.strs);
  172|  1.21k|      break;
  173|       |
  174|  1.39k|    case ARES_REC_TYPE_SIG:
  ------------------
  |  Branch (174:5): [True: 1.39k, False: 62.8k]
  ------------------
  175|  1.39k|      ares_free(rr->r.sig.signers_name);
  176|  1.39k|      ares_free(rr->r.sig.signature);
  177|  1.39k|      break;
  178|       |
  179|    643|    case ARES_REC_TYPE_SRV:
  ------------------
  |  Branch (179:5): [True: 643, False: 63.5k]
  ------------------
  180|    643|      ares_free(rr->r.srv.target);
  181|    643|      break;
  182|       |
  183|  1.04k|    case ARES_REC_TYPE_NAPTR:
  ------------------
  |  Branch (183:5): [True: 1.04k, False: 63.1k]
  ------------------
  184|  1.04k|      ares_free(rr->r.naptr.flags);
  185|  1.04k|      ares_free(rr->r.naptr.services);
  186|  1.04k|      ares_free(rr->r.naptr.regexp);
  187|  1.04k|      ares_free(rr->r.naptr.replacement);
  188|  1.04k|      break;
  189|       |
  190|  2.98k|    case ARES_REC_TYPE_OPT:
  ------------------
  |  Branch (190:5): [True: 2.98k, False: 61.2k]
  ------------------
  191|  2.98k|      ares_array_destroy(rr->r.opt.options);
  192|  2.98k|      break;
  193|       |
  194|    663|    case ARES_REC_TYPE_TLSA:
  ------------------
  |  Branch (194:5): [True: 663, False: 63.5k]
  ------------------
  195|    663|      ares_free(rr->r.tlsa.data);
  196|    663|      break;
  197|       |
  198|  1.14k|    case ARES_REC_TYPE_SVCB:
  ------------------
  |  Branch (198:5): [True: 1.14k, False: 63.1k]
  ------------------
  199|  1.14k|      ares_free(rr->r.svcb.target);
  200|  1.14k|      ares_array_destroy(rr->r.svcb.params);
  201|  1.14k|      break;
  202|       |
  203|  1.05k|    case ARES_REC_TYPE_HTTPS:
  ------------------
  |  Branch (203:5): [True: 1.05k, False: 63.1k]
  ------------------
  204|  1.05k|      ares_free(rr->r.https.target);
  205|  1.05k|      ares_array_destroy(rr->r.https.params);
  206|  1.05k|      break;
  207|       |
  208|    853|    case ARES_REC_TYPE_URI:
  ------------------
  |  Branch (208:5): [True: 853, False: 63.3k]
  ------------------
  209|    853|      ares_free(rr->r.uri.target);
  210|    853|      break;
  211|       |
  212|    638|    case ARES_REC_TYPE_CAA:
  ------------------
  |  Branch (212:5): [True: 638, False: 63.6k]
  ------------------
  213|    638|      ares_free(rr->r.caa.tag);
  214|    638|      ares_free(rr->r.caa.value);
  215|    638|      break;
  216|       |
  217|  36.3k|    case ARES_REC_TYPE_RAW_RR:
  ------------------
  |  Branch (217:5): [True: 36.3k, False: 27.9k]
  ------------------
  218|  36.3k|      ares_free(rr->r.raw_rr.data);
  219|  36.3k|      break;
  220|  64.2k|  }
  221|  64.2k|}
ares_dns_record.c:ares_dns_rr_data_ptr_const:
  751|   500k|{
  752|       |  /* We're going to cast off the const */
  753|   500k|  return ares_dns_rr_data_ptr((void *)((size_t)dns_rr), key,
  754|   500k|                              (void *)((size_t)lenptr));
  755|   500k|}
ares_dns_record.c:ares_dns_rr_data_ptr:
  548|   620k|{
  549|   620k|  if (dns_rr == NULL || dns_rr->type != ares_dns_rr_key_to_rec_type(key)) {
  ------------------
  |  Branch (549:7): [True: 0, False: 620k]
  |  Branch (549:25): [True: 0, False: 620k]
  ------------------
  550|      0|    return NULL; /* LCOV_EXCL_LINE: DefensiveCoding */
  551|      0|  }
  552|       |
  553|   620k|  switch (key) {
  ------------------
  |  Branch (553:11): [True: 620k, False: 0]
  ------------------
  554|  1.50k|    case ARES_RR_A_ADDR:
  ------------------
  |  Branch (554:5): [True: 1.50k, False: 618k]
  ------------------
  555|  1.50k|      return &dns_rr->r.a.addr;
  556|       |
  557|  3.75k|    case ARES_RR_NS_NSDNAME:
  ------------------
  |  Branch (557:5): [True: 3.75k, False: 616k]
  ------------------
  558|  3.75k|      return &dns_rr->r.ns.nsdname;
  559|       |
  560|  3.15k|    case ARES_RR_CNAME_CNAME:
  ------------------
  |  Branch (560:5): [True: 3.15k, False: 617k]
  ------------------
  561|  3.15k|      return &dns_rr->r.cname.cname;
  562|       |
  563|  2.68k|    case ARES_RR_SOA_MNAME:
  ------------------
  |  Branch (563:5): [True: 2.68k, False: 617k]
  ------------------
  564|  2.68k|      return &dns_rr->r.soa.mname;
  565|       |
  566|  2.63k|    case ARES_RR_SOA_RNAME:
  ------------------
  |  Branch (566:5): [True: 2.63k, False: 617k]
  ------------------
  567|  2.63k|      return &dns_rr->r.soa.rname;
  568|       |
  569|  2.62k|    case ARES_RR_SOA_SERIAL:
  ------------------
  |  Branch (569:5): [True: 2.62k, False: 617k]
  ------------------
  570|  2.62k|      return &dns_rr->r.soa.serial;
  571|       |
  572|  2.62k|    case ARES_RR_SOA_REFRESH:
  ------------------
  |  Branch (572:5): [True: 2.62k, False: 617k]
  ------------------
  573|  2.62k|      return &dns_rr->r.soa.refresh;
  574|       |
  575|  2.62k|    case ARES_RR_SOA_RETRY:
  ------------------
  |  Branch (575:5): [True: 2.62k, False: 617k]
  ------------------
  576|  2.62k|      return &dns_rr->r.soa.retry;
  577|       |
  578|  2.62k|    case ARES_RR_SOA_EXPIRE:
  ------------------
  |  Branch (578:5): [True: 2.62k, False: 617k]
  ------------------
  579|  2.62k|      return &dns_rr->r.soa.expire;
  580|       |
  581|  2.62k|    case ARES_RR_SOA_MINIMUM:
  ------------------
  |  Branch (581:5): [True: 2.62k, False: 617k]
  ------------------
  582|  2.62k|      return &dns_rr->r.soa.minimum;
  583|       |
  584|  1.56k|    case ARES_RR_PTR_DNAME:
  ------------------
  |  Branch (584:5): [True: 1.56k, False: 618k]
  ------------------
  585|  1.56k|      return &dns_rr->r.ptr.dname;
  586|       |
  587|  13.7k|    case ARES_RR_AAAA_ADDR:
  ------------------
  |  Branch (587:5): [True: 13.7k, False: 606k]
  ------------------
  588|  13.7k|      return &dns_rr->r.aaaa.addr;
  589|       |
  590|  2.84k|    case ARES_RR_HINFO_CPU:
  ------------------
  |  Branch (590:5): [True: 2.84k, False: 617k]
  ------------------
  591|  2.84k|      return &dns_rr->r.hinfo.cpu;
  592|       |
  593|  2.82k|    case ARES_RR_HINFO_OS:
  ------------------
  |  Branch (593:5): [True: 2.82k, False: 617k]
  ------------------
  594|  2.82k|      return &dns_rr->r.hinfo.os;
  595|       |
  596|  6.72k|    case ARES_RR_MX_PREFERENCE:
  ------------------
  |  Branch (596:5): [True: 6.72k, False: 613k]
  ------------------
  597|  6.72k|      return &dns_rr->r.mx.preference;
  598|       |
  599|  6.72k|    case ARES_RR_MX_EXCHANGE:
  ------------------
  |  Branch (599:5): [True: 6.72k, False: 613k]
  ------------------
  600|  6.72k|      return &dns_rr->r.mx.exchange;
  601|       |
  602|  3.22k|    case ARES_RR_SIG_TYPE_COVERED:
  ------------------
  |  Branch (602:5): [True: 3.22k, False: 617k]
  ------------------
  603|  3.22k|      return &dns_rr->r.sig.type_covered;
  604|       |
  605|  3.21k|    case ARES_RR_SIG_ALGORITHM:
  ------------------
  |  Branch (605:5): [True: 3.21k, False: 617k]
  ------------------
  606|  3.21k|      return &dns_rr->r.sig.algorithm;
  607|       |
  608|  3.21k|    case ARES_RR_SIG_LABELS:
  ------------------
  |  Branch (608:5): [True: 3.21k, False: 617k]
  ------------------
  609|  3.21k|      return &dns_rr->r.sig.labels;
  610|       |
  611|  3.21k|    case ARES_RR_SIG_ORIGINAL_TTL:
  ------------------
  |  Branch (611:5): [True: 3.21k, False: 617k]
  ------------------
  612|  3.21k|      return &dns_rr->r.sig.original_ttl;
  613|       |
  614|  3.21k|    case ARES_RR_SIG_EXPIRATION:
  ------------------
  |  Branch (614:5): [True: 3.21k, False: 617k]
  ------------------
  615|  3.21k|      return &dns_rr->r.sig.expiration;
  616|       |
  617|  3.21k|    case ARES_RR_SIG_INCEPTION:
  ------------------
  |  Branch (617:5): [True: 3.21k, False: 617k]
  ------------------
  618|  3.21k|      return &dns_rr->r.sig.inception;
  619|       |
  620|  3.21k|    case ARES_RR_SIG_KEY_TAG:
  ------------------
  |  Branch (620:5): [True: 3.21k, False: 617k]
  ------------------
  621|  3.21k|      return &dns_rr->r.sig.key_tag;
  622|       |
  623|  3.21k|    case ARES_RR_SIG_SIGNERS_NAME:
  ------------------
  |  Branch (623:5): [True: 3.21k, False: 617k]
  ------------------
  624|  3.21k|      return &dns_rr->r.sig.signers_name;
  625|       |
  626|  2.26k|    case ARES_RR_SIG_SIGNATURE:
  ------------------
  |  Branch (626:5): [True: 2.26k, False: 618k]
  ------------------
  627|  2.26k|      if (lenptr == NULL) {
  ------------------
  |  Branch (627:11): [True: 0, False: 2.26k]
  ------------------
  628|      0|        return NULL;
  629|      0|      }
  630|  2.26k|      *lenptr = &dns_rr->r.sig.signature_len;
  631|  2.26k|      return &dns_rr->r.sig.signature;
  632|       |
  633|   361k|    case ARES_RR_TXT_DATA:
  ------------------
  |  Branch (633:5): [True: 361k, False: 259k]
  ------------------
  634|   361k|      return &dns_rr->r.txt.strs;
  635|       |
  636|  1.63k|    case ARES_RR_SRV_PRIORITY:
  ------------------
  |  Branch (636:5): [True: 1.63k, False: 618k]
  ------------------
  637|  1.63k|      return &dns_rr->r.srv.priority;
  638|       |
  639|  1.63k|    case ARES_RR_SRV_WEIGHT:
  ------------------
  |  Branch (639:5): [True: 1.63k, False: 618k]
  ------------------
  640|  1.63k|      return &dns_rr->r.srv.weight;
  641|       |
  642|  1.63k|    case ARES_RR_SRV_PORT:
  ------------------
  |  Branch (642:5): [True: 1.63k, False: 618k]
  ------------------
  643|  1.63k|      return &dns_rr->r.srv.port;
  644|       |
  645|  1.63k|    case ARES_RR_SRV_TARGET:
  ------------------
  |  Branch (645:5): [True: 1.63k, False: 618k]
  ------------------
  646|  1.63k|      return &dns_rr->r.srv.target;
  647|       |
  648|  2.57k|    case ARES_RR_NAPTR_ORDER:
  ------------------
  |  Branch (648:5): [True: 2.57k, False: 617k]
  ------------------
  649|  2.57k|      return &dns_rr->r.naptr.order;
  650|       |
  651|  2.57k|    case ARES_RR_NAPTR_PREFERENCE:
  ------------------
  |  Branch (651:5): [True: 2.57k, False: 617k]
  ------------------
  652|  2.57k|      return &dns_rr->r.naptr.preference;
  653|       |
  654|  2.57k|    case ARES_RR_NAPTR_FLAGS:
  ------------------
  |  Branch (654:5): [True: 2.57k, False: 617k]
  ------------------
  655|  2.57k|      return &dns_rr->r.naptr.flags;
  656|       |
  657|  2.57k|    case ARES_RR_NAPTR_SERVICES:
  ------------------
  |  Branch (657:5): [True: 2.57k, False: 617k]
  ------------------
  658|  2.57k|      return &dns_rr->r.naptr.services;
  659|       |
  660|  2.56k|    case ARES_RR_NAPTR_REGEXP:
  ------------------
  |  Branch (660:5): [True: 2.56k, False: 617k]
  ------------------
  661|  2.56k|      return &dns_rr->r.naptr.regexp;
  662|       |
  663|  2.56k|    case ARES_RR_NAPTR_REPLACEMENT:
  ------------------
  |  Branch (663:5): [True: 2.56k, False: 617k]
  ------------------
  664|  2.56k|      return &dns_rr->r.naptr.replacement;
  665|       |
  666|  7.80k|    case ARES_RR_OPT_UDP_SIZE:
  ------------------
  |  Branch (666:5): [True: 7.80k, False: 612k]
  ------------------
  667|  7.80k|      return &dns_rr->r.opt.udp_size;
  668|       |
  669|  7.80k|    case ARES_RR_OPT_VERSION:
  ------------------
  |  Branch (669:5): [True: 7.80k, False: 612k]
  ------------------
  670|  7.80k|      return &dns_rr->r.opt.version;
  671|       |
  672|  7.80k|    case ARES_RR_OPT_FLAGS:
  ------------------
  |  Branch (672:5): [True: 7.80k, False: 612k]
  ------------------
  673|  7.80k|      return &dns_rr->r.opt.flags;
  674|       |
  675|  6.56k|    case ARES_RR_OPT_OPTIONS:
  ------------------
  |  Branch (675:5): [True: 6.56k, False: 613k]
  ------------------
  676|  6.56k|      return &dns_rr->r.opt.options;
  677|       |
  678|  1.85k|    case ARES_RR_TLSA_CERT_USAGE:
  ------------------
  |  Branch (678:5): [True: 1.85k, False: 618k]
  ------------------
  679|  1.85k|      return &dns_rr->r.tlsa.cert_usage;
  680|       |
  681|  1.85k|    case ARES_RR_TLSA_SELECTOR:
  ------------------
  |  Branch (681:5): [True: 1.85k, False: 618k]
  ------------------
  682|  1.85k|      return &dns_rr->r.tlsa.selector;
  683|       |
  684|  1.85k|    case ARES_RR_TLSA_MATCH:
  ------------------
  |  Branch (684:5): [True: 1.85k, False: 618k]
  ------------------
  685|  1.85k|      return &dns_rr->r.tlsa.match;
  686|       |
  687|  1.23k|    case ARES_RR_TLSA_DATA:
  ------------------
  |  Branch (687:5): [True: 1.23k, False: 619k]
  ------------------
  688|  1.23k|      if (lenptr == NULL) {
  ------------------
  |  Branch (688:11): [True: 0, False: 1.23k]
  ------------------
  689|      0|        return NULL;
  690|      0|      }
  691|  1.23k|      *lenptr = &dns_rr->r.tlsa.data_len;
  692|  1.23k|      return &dns_rr->r.tlsa.data;
  693|       |
  694|  2.89k|    case ARES_RR_SVCB_PRIORITY:
  ------------------
  |  Branch (694:5): [True: 2.89k, False: 617k]
  ------------------
  695|  2.89k|      return &dns_rr->r.svcb.priority;
  696|       |
  697|  2.89k|    case ARES_RR_SVCB_TARGET:
  ------------------
  |  Branch (697:5): [True: 2.89k, False: 617k]
  ------------------
  698|  2.89k|      return &dns_rr->r.svcb.target;
  699|       |
  700|  7.93k|    case ARES_RR_SVCB_PARAMS:
  ------------------
  |  Branch (700:5): [True: 7.93k, False: 612k]
  ------------------
  701|  7.93k|      return &dns_rr->r.svcb.params;
  702|       |
  703|  2.51k|    case ARES_RR_HTTPS_PRIORITY:
  ------------------
  |  Branch (703:5): [True: 2.51k, False: 617k]
  ------------------
  704|  2.51k|      return &dns_rr->r.https.priority;
  705|       |
  706|  2.51k|    case ARES_RR_HTTPS_TARGET:
  ------------------
  |  Branch (706:5): [True: 2.51k, False: 617k]
  ------------------
  707|  2.51k|      return &dns_rr->r.https.target;
  708|       |
  709|  6.35k|    case ARES_RR_HTTPS_PARAMS:
  ------------------
  |  Branch (709:5): [True: 6.35k, False: 613k]
  ------------------
  710|  6.35k|      return &dns_rr->r.https.params;
  711|       |
  712|  1.79k|    case ARES_RR_URI_PRIORITY:
  ------------------
  |  Branch (712:5): [True: 1.79k, False: 618k]
  ------------------
  713|  1.79k|      return &dns_rr->r.uri.priority;
  714|       |
  715|  1.79k|    case ARES_RR_URI_WEIGHT:
  ------------------
  |  Branch (715:5): [True: 1.79k, False: 618k]
  ------------------
  716|  1.79k|      return &dns_rr->r.uri.weight;
  717|       |
  718|  1.76k|    case ARES_RR_URI_TARGET:
  ------------------
  |  Branch (718:5): [True: 1.76k, False: 618k]
  ------------------
  719|  1.76k|      return &dns_rr->r.uri.target;
  720|       |
  721|  1.70k|    case ARES_RR_CAA_CRITICAL:
  ------------------
  |  Branch (721:5): [True: 1.70k, False: 618k]
  ------------------
  722|  1.70k|      return &dns_rr->r.caa.critical;
  723|       |
  724|  1.69k|    case ARES_RR_CAA_TAG:
  ------------------
  |  Branch (724:5): [True: 1.69k, False: 618k]
  ------------------
  725|  1.69k|      return &dns_rr->r.caa.tag;
  726|       |
  727|  1.69k|    case ARES_RR_CAA_VALUE:
  ------------------
  |  Branch (727:5): [True: 1.69k, False: 618k]
  ------------------
  728|  1.69k|      if (lenptr == NULL) {
  ------------------
  |  Branch (728:11): [True: 0, False: 1.69k]
  ------------------
  729|      0|        return NULL;
  730|      0|      }
  731|  1.69k|      *lenptr = &dns_rr->r.caa.value_len;
  732|  1.69k|      return &dns_rr->r.caa.value;
  733|       |
  734|  70.6k|    case ARES_RR_RAW_RR_TYPE:
  ------------------
  |  Branch (734:5): [True: 70.6k, False: 549k]
  ------------------
  735|  70.6k|      return &dns_rr->r.raw_rr.type;
  736|       |
  737|  5.01k|    case ARES_RR_RAW_RR_DATA:
  ------------------
  |  Branch (737:5): [True: 5.01k, False: 615k]
  ------------------
  738|  5.01k|      if (lenptr == NULL) {
  ------------------
  |  Branch (738:11): [True: 0, False: 5.01k]
  ------------------
  739|      0|        return NULL;
  740|      0|      }
  741|  5.01k|      *lenptr = &dns_rr->r.raw_rr.length;
  742|  5.01k|      return &dns_rr->r.raw_rr.data;
  743|   620k|  }
  744|       |
  745|      0|  return NULL;
  746|   620k|}
ares_dns_record.c:ares_dns_opt_free_cb:
 1339|  5.60k|{
 1340|  5.60k|  ares_dns_optval_t *opt = arg;
 1341|  5.60k|  if (opt == NULL) {
  ------------------
  |  Branch (1341:7): [True: 0, False: 5.60k]
  ------------------
 1342|      0|    return;
 1343|      0|  }
 1344|  5.60k|  ares_free(opt->val);
 1345|  5.60k|}

ares_dns_write_buf:
 1099|  1.82k|{
 1100|  1.82k|  ares_llist_t *namelist = NULL;
 1101|  1.82k|  size_t        orig_len;
 1102|  1.82k|  ares_status_t status;
 1103|       |
 1104|  1.82k|  if (dnsrec == NULL || buf == NULL) {
  ------------------
  |  Branch (1104:7): [True: 0, False: 1.82k]
  |  Branch (1104:25): [True: 0, False: 1.82k]
  ------------------
 1105|      0|    return ARES_EFORMERR;
 1106|      0|  }
 1107|       |
 1108|  1.82k|  orig_len = ares_buf_len(buf);
 1109|       |
 1110|  1.82k|  status = ares_dns_write_header(dnsrec, buf);
 1111|  1.82k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1111:7): [True: 0, False: 1.82k]
  ------------------
 1112|      0|    goto done;
 1113|      0|  }
 1114|       |
 1115|  1.82k|  status = ares_dns_write_questions(dnsrec, &namelist, buf);
 1116|  1.82k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1116:7): [True: 143, False: 1.67k]
  ------------------
 1117|    143|    goto done;
 1118|    143|  }
 1119|       |
 1120|  1.67k|  status = ares_dns_write_rr(dnsrec, &namelist, ARES_SECTION_ANSWER, buf);
 1121|  1.67k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1121:7): [True: 230, False: 1.44k]
  ------------------
 1122|    230|    goto done;
 1123|    230|  }
 1124|       |
 1125|  1.44k|  status = ares_dns_write_rr(dnsrec, &namelist, ARES_SECTION_AUTHORITY, buf);
 1126|  1.44k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1126:7): [True: 245, False: 1.20k]
  ------------------
 1127|    245|    goto done;
 1128|    245|  }
 1129|       |
 1130|  1.20k|  status = ares_dns_write_rr(dnsrec, &namelist, ARES_SECTION_ADDITIONAL, buf);
 1131|  1.20k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1131:7): [True: 155, False: 1.04k]
  ------------------
 1132|    155|    goto done;
 1133|    155|  }
 1134|       |
 1135|  1.82k|done:
 1136|  1.82k|  ares_llist_destroy(namelist);
 1137|  1.82k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1137:7): [True: 773, False: 1.04k]
  ------------------
 1138|    773|    ares_buf_set_length(buf, orig_len);
 1139|    773|  }
 1140|       |
 1141|  1.82k|  return status;
 1142|  1.20k|}
ares_dns_write:
 1195|  1.82k|{
 1196|  1.82k|  ares_buf_t   *b = NULL;
 1197|  1.82k|  ares_status_t status;
 1198|       |
 1199|  1.82k|  if (buf == NULL || buf_len == NULL || dnsrec == NULL) {
  ------------------
  |  Branch (1199:7): [True: 0, False: 1.82k]
  |  Branch (1199:22): [True: 0, False: 1.82k]
  |  Branch (1199:41): [True: 0, False: 1.82k]
  ------------------
 1200|      0|    return ARES_EFORMERR;
 1201|      0|  }
 1202|       |
 1203|  1.82k|  *buf     = NULL;
 1204|  1.82k|  *buf_len = 0;
 1205|       |
 1206|  1.82k|  b = ares_buf_create();
 1207|  1.82k|  if (b == NULL) {
  ------------------
  |  Branch (1207:7): [True: 0, False: 1.82k]
  ------------------
 1208|      0|    return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
 1209|      0|  }
 1210|       |
 1211|  1.82k|  status = ares_dns_write_buf(dnsrec, b);
 1212|       |
 1213|  1.82k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1213:7): [True: 773, False: 1.04k]
  ------------------
 1214|    773|    ares_buf_destroy(b);
 1215|    773|    return status;
 1216|    773|  }
 1217|       |
 1218|  1.04k|  *buf = ares_buf_finish_bin(b, buf_len);
 1219|  1.04k|  return status;
 1220|  1.82k|}
ares_dns_write.c:ares_dns_write_header:
   35|  1.82k|{
   36|  1.82k|  unsigned short u16;
   37|  1.82k|  unsigned short opcode;
   38|  1.82k|  unsigned short rcode;
   39|       |
   40|  1.82k|  ares_status_t  status;
   41|       |
   42|       |  /* ID */
   43|  1.82k|  status = ares_buf_append_be16(buf, dnsrec->id);
   44|  1.82k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (44:7): [True: 0, False: 1.82k]
  ------------------
   45|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
   46|      0|  }
   47|       |
   48|       |  /* Flags */
   49|  1.82k|  u16 = 0;
   50|       |
   51|       |  /* QR */
   52|  1.82k|  if (dnsrec->flags & ARES_FLAG_QR) {
  ------------------
  |  Branch (52:7): [True: 667, False: 1.15k]
  ------------------
   53|    667|    u16 |= 0x8000;
   54|    667|  }
   55|       |
   56|       |  /* OPCODE */
   57|  1.82k|  opcode   = (unsigned short)(dnsrec->opcode & 0xF);
   58|  1.82k|  opcode <<= 11;
   59|  1.82k|  u16     |= opcode;
   60|       |
   61|       |  /* AA */
   62|  1.82k|  if (dnsrec->flags & ARES_FLAG_AA) {
  ------------------
  |  Branch (62:7): [True: 474, False: 1.34k]
  ------------------
   63|    474|    u16 |= 0x400;
   64|    474|  }
   65|       |
   66|       |  /* TC */
   67|  1.82k|  if (dnsrec->flags & ARES_FLAG_TC) {
  ------------------
  |  Branch (67:7): [True: 395, False: 1.42k]
  ------------------
   68|    395|    u16 |= 0x200;
   69|    395|  }
   70|       |
   71|       |  /* RD */
   72|  1.82k|  if (dnsrec->flags & ARES_FLAG_RD) {
  ------------------
  |  Branch (72:7): [True: 768, False: 1.05k]
  ------------------
   73|    768|    u16 |= 0x100;
   74|    768|  }
   75|       |
   76|       |  /* RA */
   77|  1.82k|  if (dnsrec->flags & ARES_FLAG_RA) {
  ------------------
  |  Branch (77:7): [True: 666, False: 1.15k]
  ------------------
   78|    666|    u16 |= 0x80;
   79|    666|  }
   80|       |
   81|       |  /* Z -- unused */
   82|       |
   83|       |  /* AD */
   84|  1.82k|  if (dnsrec->flags & ARES_FLAG_AD) {
  ------------------
  |  Branch (84:7): [True: 553, False: 1.26k]
  ------------------
   85|    553|    u16 |= 0x20;
   86|    553|  }
   87|       |
   88|       |  /* CD */
   89|  1.82k|  if (dnsrec->flags & ARES_FLAG_CD) {
  ------------------
  |  Branch (89:7): [True: 490, False: 1.33k]
  ------------------
   90|    490|    u16 |= 0x10;
   91|    490|  }
   92|       |
   93|       |  /* RCODE */
   94|  1.82k|  if (dnsrec->rcode > 15 && ares_dns_get_opt_rr_const(dnsrec) == NULL) {
  ------------------
  |  Branch (94:7): [True: 57, False: 1.76k]
  |  Branch (94:29): [True: 40, False: 17]
  ------------------
   95|       |    /* Must have OPT RR in order to write extended error codes */
   96|     40|    rcode = ARES_RCODE_SERVFAIL;
   97|  1.78k|  } else {
   98|  1.78k|    rcode = (unsigned short)(dnsrec->rcode & 0xF);
   99|  1.78k|  }
  100|  1.82k|  u16 |= rcode;
  101|       |
  102|  1.82k|  status = ares_buf_append_be16(buf, u16);
  103|  1.82k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (103:7): [True: 0, False: 1.82k]
  ------------------
  104|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  105|      0|  }
  106|       |
  107|       |  /* QDCOUNT */
  108|  1.82k|  status = ares_buf_append_be16(
  109|  1.82k|    buf, (unsigned short)ares_dns_record_query_cnt(dnsrec));
  110|  1.82k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (110:7): [True: 0, False: 1.82k]
  ------------------
  111|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  112|      0|  }
  113|       |
  114|       |  /* ANCOUNT */
  115|  1.82k|  status = ares_buf_append_be16(
  116|  1.82k|    buf, (unsigned short)ares_dns_record_rr_cnt(dnsrec, ARES_SECTION_ANSWER));
  117|  1.82k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (117:7): [True: 0, False: 1.82k]
  ------------------
  118|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  119|      0|  }
  120|       |
  121|       |  /* NSCOUNT */
  122|  1.82k|  status = ares_buf_append_be16(buf, (unsigned short)ares_dns_record_rr_cnt(
  123|  1.82k|                                       dnsrec, ARES_SECTION_AUTHORITY));
  124|  1.82k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (124:7): [True: 0, False: 1.82k]
  ------------------
  125|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  126|      0|  }
  127|       |
  128|       |  /* ARCOUNT */
  129|  1.82k|  status = ares_buf_append_be16(buf, (unsigned short)ares_dns_record_rr_cnt(
  130|  1.82k|                                       dnsrec, ARES_SECTION_ADDITIONAL));
  131|  1.82k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (131:7): [True: 0, False: 1.82k]
  ------------------
  132|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  133|      0|  }
  134|       |
  135|  1.82k|  return ARES_SUCCESS;
  136|  1.82k|}
ares_dns_write.c:ares_dns_write_questions:
  141|  1.82k|{
  142|  1.82k|  size_t i;
  143|       |
  144|  3.50k|  for (i = 0; i < ares_dns_record_query_cnt(dnsrec); i++) {
  ------------------
  |  Branch (144:15): [True: 1.82k, False: 1.67k]
  ------------------
  145|  1.82k|    ares_status_t       status;
  146|  1.82k|    const char         *name = NULL;
  147|  1.82k|    ares_dns_rec_type_t qtype;
  148|  1.82k|    ares_dns_class_t    qclass;
  149|       |
  150|  1.82k|    status = ares_dns_record_query_get(dnsrec, i, &name, &qtype, &qclass);
  151|  1.82k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (151:9): [True: 0, False: 1.82k]
  ------------------
  152|      0|      return status;
  153|      0|    }
  154|       |
  155|       |    /* Name */
  156|  1.82k|    status = ares_dns_name_write(buf, namelist, ARES_TRUE, name);
  157|  1.82k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (157:9): [True: 143, False: 1.67k]
  ------------------
  158|    143|      return status;
  159|    143|    }
  160|       |
  161|       |    /* Type */
  162|  1.67k|    status = ares_buf_append_be16(buf, (unsigned short)qtype);
  163|  1.67k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (163:9): [True: 0, False: 1.67k]
  ------------------
  164|      0|      return status; /* LCOV_EXCL_LINE: OutOfMemory */
  165|      0|    }
  166|       |
  167|       |    /* Class */
  168|  1.67k|    status = ares_buf_append_be16(buf, (unsigned short)qclass);
  169|  1.67k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (169:9): [True: 0, False: 1.67k]
  ------------------
  170|      0|      return status; /* LCOV_EXCL_LINE: OutOfMemory */
  171|      0|    }
  172|  1.67k|  }
  173|       |
  174|  1.67k|  return ARES_SUCCESS;
  175|  1.82k|}
ares_dns_write.c:ares_dns_write_rr:
  941|  4.33k|{
  942|  4.33k|  size_t i;
  943|       |
  944|  19.6k|  for (i = 0; i < ares_dns_record_rr_cnt(dnsrec, section); i++) {
  ------------------
  |  Branch (944:15): [True: 15.9k, False: 3.70k]
  ------------------
  945|  15.9k|    const ares_dns_rr_t *rr;
  946|  15.9k|    ares_dns_rec_type_t  type;
  947|  15.9k|    ares_bool_t          allow_compress;
  948|  15.9k|    ares_llist_t       **namelistptr = NULL;
  949|  15.9k|    size_t               pos_len;
  950|  15.9k|    ares_status_t        status;
  951|  15.9k|    size_t               rdlength;
  952|  15.9k|    size_t               end_length;
  953|  15.9k|    unsigned int         ttl;
  954|       |
  955|  15.9k|    rr = ares_dns_record_rr_get_const(dnsrec, section, i);
  956|  15.9k|    if (rr == NULL) {
  ------------------
  |  Branch (956:9): [True: 0, False: 15.9k]
  ------------------
  957|      0|      return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
  958|      0|    }
  959|       |
  960|  15.9k|    type           = ares_dns_rr_get_type(rr);
  961|  15.9k|    allow_compress = ares_dns_rec_allow_name_comp(type);
  962|  15.9k|    if (allow_compress) {
  ------------------
  |  Branch (962:9): [True: 5.79k, False: 10.2k]
  ------------------
  963|  5.79k|      namelistptr = namelist;
  964|  5.79k|    }
  965|       |
  966|       |    /* Name */
  967|  15.9k|    status =
  968|  15.9k|      ares_dns_name_write(buf, namelist, ARES_TRUE, ares_dns_rr_get_name(rr));
  969|  15.9k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (969:9): [True: 206, False: 15.7k]
  ------------------
  970|    206|      return status;
  971|    206|    }
  972|       |
  973|       |    /* Type */
  974|  15.7k|    status = ares_buf_append_be16(buf, (unsigned short)type);
  975|  15.7k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (975:9): [True: 0, False: 15.7k]
  ------------------
  976|      0|      return status; /* LCOV_EXCL_LINE: OutOfMemory */
  977|      0|    }
  978|       |
  979|       |    /* Class */
  980|  15.7k|    status =
  981|  15.7k|      ares_buf_append_be16(buf, (unsigned short)ares_dns_rr_get_class(rr));
  982|  15.7k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (982:9): [True: 0, False: 15.7k]
  ------------------
  983|      0|      return status; /* LCOV_EXCL_LINE: OutOfMemory */
  984|      0|    }
  985|       |
  986|       |    /* TTL */
  987|  15.7k|    ttl = ares_dns_rr_get_ttl(rr);
  988|  15.7k|    if (rr->parent->ttl_decrement > ttl) {
  ------------------
  |  Branch (988:9): [True: 0, False: 15.7k]
  ------------------
  989|      0|      ttl = 0;
  990|  15.7k|    } else {
  991|  15.7k|      ttl -= rr->parent->ttl_decrement;
  992|  15.7k|    }
  993|  15.7k|    status = ares_buf_append_be32(buf, ttl);
  994|  15.7k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (994:9): [True: 0, False: 15.7k]
  ------------------
  995|      0|      return status; /* LCOV_EXCL_LINE: OutOfMemory */
  996|      0|    }
  997|       |
  998|       |    /* Length */
  999|  15.7k|    pos_len = ares_buf_len(buf); /* Save to write real length later */
 1000|  15.7k|    status  = ares_buf_append_be16(buf, 0);
 1001|  15.7k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1001:9): [True: 0, False: 15.7k]
  ------------------
 1002|      0|      return status; /* LCOV_EXCL_LINE: OutOfMemory */
 1003|      0|    }
 1004|       |
 1005|       |    /* Data */
 1006|  15.7k|    switch (type) {
  ------------------
  |  Branch (1006:13): [True: 15.7k, False: 0]
  ------------------
 1007|    423|      case ARES_REC_TYPE_A:
  ------------------
  |  Branch (1007:7): [True: 423, False: 15.3k]
  ------------------
 1008|    423|        status = ares_dns_write_rr_a(buf, rr, namelistptr);
 1009|    423|        break;
 1010|  1.16k|      case ARES_REC_TYPE_NS:
  ------------------
  |  Branch (1010:7): [True: 1.16k, False: 14.6k]
  ------------------
 1011|  1.16k|        status = ares_dns_write_rr_ns(buf, rr, namelistptr);
 1012|  1.16k|        break;
 1013|    882|      case ARES_REC_TYPE_CNAME:
  ------------------
  |  Branch (1013:7): [True: 882, False: 14.9k]
  ------------------
 1014|    882|        status = ares_dns_write_rr_cname(buf, rr, namelistptr);
 1015|    882|        break;
 1016|    715|      case ARES_REC_TYPE_SOA:
  ------------------
  |  Branch (1016:7): [True: 715, False: 15.0k]
  ------------------
 1017|    715|        status = ares_dns_write_rr_soa(buf, rr, namelistptr);
 1018|    715|        break;
 1019|    478|      case ARES_REC_TYPE_PTR:
  ------------------
  |  Branch (1019:7): [True: 478, False: 15.3k]
  ------------------
 1020|    478|        status = ares_dns_write_rr_ptr(buf, rr, namelistptr);
 1021|    478|        break;
 1022|    718|      case ARES_REC_TYPE_HINFO:
  ------------------
  |  Branch (1022:7): [True: 718, False: 15.0k]
  ------------------
 1023|    718|        status = ares_dns_write_rr_hinfo(buf, rr, namelistptr);
 1024|    718|        break;
 1025|    411|      case ARES_REC_TYPE_MX:
  ------------------
  |  Branch (1025:7): [True: 411, False: 15.3k]
  ------------------
 1026|    411|        status = ares_dns_write_rr_mx(buf, rr, namelistptr);
 1027|    411|        break;
 1028|    972|      case ARES_REC_TYPE_TXT:
  ------------------
  |  Branch (1028:7): [True: 972, False: 14.8k]
  ------------------
 1029|    972|        status = ares_dns_write_rr_txt(buf, rr, namelistptr);
 1030|    972|        break;
 1031|    888|      case ARES_REC_TYPE_SIG:
  ------------------
  |  Branch (1031:7): [True: 888, False: 14.8k]
  ------------------
 1032|    888|        status = ares_dns_write_rr_sig(buf, rr, namelistptr);
 1033|    888|        break;
 1034|  1.03k|      case ARES_REC_TYPE_AAAA:
  ------------------
  |  Branch (1034:7): [True: 1.03k, False: 14.7k]
  ------------------
 1035|  1.03k|        status = ares_dns_write_rr_aaaa(buf, rr, namelistptr);
 1036|  1.03k|        break;
 1037|    416|      case ARES_REC_TYPE_SRV:
  ------------------
  |  Branch (1037:7): [True: 416, False: 15.3k]
  ------------------
 1038|    416|        status = ares_dns_write_rr_srv(buf, rr, namelistptr);
 1039|    416|        break;
 1040|    758|      case ARES_REC_TYPE_NAPTR:
  ------------------
  |  Branch (1040:7): [True: 758, False: 15.0k]
  ------------------
 1041|    758|        status = ares_dns_write_rr_naptr(buf, rr, namelistptr);
 1042|    758|        break;
 1043|      0|      case ARES_REC_TYPE_ANY:
  ------------------
  |  Branch (1043:7): [True: 0, False: 15.7k]
  ------------------
 1044|      0|        status = ARES_EFORMERR;
 1045|      0|        break;
 1046|  2.18k|      case ARES_REC_TYPE_OPT:
  ------------------
  |  Branch (1046:7): [True: 2.18k, False: 13.6k]
  ------------------
 1047|  2.18k|        status = ares_dns_write_rr_opt(buf, rr, namelistptr);
 1048|  2.18k|        break;
 1049|    578|      case ARES_REC_TYPE_TLSA:
  ------------------
  |  Branch (1049:7): [True: 578, False: 15.2k]
  ------------------
 1050|    578|        status = ares_dns_write_rr_tlsa(buf, rr, namelistptr);
 1051|    578|        break;
 1052|    812|      case ARES_REC_TYPE_SVCB:
  ------------------
  |  Branch (1052:7): [True: 812, False: 14.9k]
  ------------------
 1053|    812|        status = ares_dns_write_rr_svcb(buf, rr, namelistptr);
 1054|    812|        break;
 1055|    725|      case ARES_REC_TYPE_HTTPS:
  ------------------
  |  Branch (1055:7): [True: 725, False: 15.0k]
  ------------------
 1056|    725|        status = ares_dns_write_rr_https(buf, rr, namelistptr);
 1057|    725|        break;
 1058|    417|      case ARES_REC_TYPE_URI:
  ------------------
  |  Branch (1058:7): [True: 417, False: 15.3k]
  ------------------
 1059|    417|        status = ares_dns_write_rr_uri(buf, rr, namelistptr);
 1060|    417|        break;
 1061|    525|      case ARES_REC_TYPE_CAA:
  ------------------
  |  Branch (1061:7): [True: 525, False: 15.2k]
  ------------------
 1062|    525|        status = ares_dns_write_rr_caa(buf, rr, namelistptr);
 1063|    525|        break;
 1064|  1.68k|      case ARES_REC_TYPE_RAW_RR:
  ------------------
  |  Branch (1064:7): [True: 1.68k, False: 14.0k]
  ------------------
 1065|  1.68k|        status = ares_dns_write_rr_raw_rr(buf, rr, namelistptr);
 1066|  1.68k|        break;
 1067|  15.7k|    }
 1068|       |
 1069|  15.7k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1069:9): [True: 424, False: 15.3k]
  ------------------
 1070|    424|      return status;
 1071|    424|    }
 1072|       |
 1073|       |    /* Back off write pointer, write real length, then go back to proper
 1074|       |     * position */
 1075|  15.3k|    end_length = ares_buf_len(buf);
 1076|  15.3k|    rdlength   = end_length - pos_len - 2;
 1077|       |
 1078|  15.3k|    status = ares_buf_set_length(buf, pos_len);
 1079|  15.3k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1079:9): [True: 0, False: 15.3k]
  ------------------
 1080|      0|      return status;
 1081|      0|    }
 1082|       |
 1083|  15.3k|    status = ares_buf_append_be16(buf, (unsigned short)(rdlength & 0xFFFF));
 1084|  15.3k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1084:9): [True: 0, False: 15.3k]
  ------------------
 1085|      0|      return status; /* LCOV_EXCL_LINE: OutOfMemory */
 1086|      0|    }
 1087|       |
 1088|  15.3k|    status = ares_buf_set_length(buf, end_length);
 1089|  15.3k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1089:9): [True: 0, False: 15.3k]
  ------------------
 1090|      0|      return status;
 1091|      0|    }
 1092|  15.3k|  }
 1093|       |
 1094|  3.70k|  return ARES_SUCCESS;
 1095|  4.33k|}
ares_dns_write.c:ares_dns_write_rr_a:
  323|    423|{
  324|    423|  const struct in_addr *addr;
  325|    423|  (void)namelist;
  326|       |
  327|    423|  addr = ares_dns_rr_get_addr(rr, ARES_RR_A_ADDR);
  328|    423|  if (addr == NULL) {
  ------------------
  |  Branch (328:7): [True: 0, False: 423]
  ------------------
  329|      0|    return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
  330|      0|  }
  331|       |
  332|    423|  return ares_buf_append(buf, (const unsigned char *)addr, sizeof(*addr));
  333|    423|}
ares_dns_write.c:ares_dns_write_rr_ns:
  338|  1.16k|{
  339|  1.16k|  return ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE,
  340|  1.16k|                                ARES_RR_NS_NSDNAME);
  341|  1.16k|}
ares_dns_write.c:ares_dns_write_rr_name:
  182|  7.91k|{
  183|  7.91k|  const char *name;
  184|       |
  185|  7.91k|  name = ares_dns_rr_get_str(rr, key);
  186|  7.91k|  if (name == NULL) {
  ------------------
  |  Branch (186:7): [True: 0, False: 7.91k]
  ------------------
  187|      0|    return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
  188|      0|  }
  189|       |
  190|  7.91k|  return ares_dns_name_write(buf, namelist, validate_hostname, name);
  191|  7.91k|}
ares_dns_write.c:ares_dns_write_rr_cname:
  346|    882|{
  347|    882|  return ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE,
  348|    882|                                ARES_RR_CNAME_CNAME);
  349|    882|}
ares_dns_write.c:ares_dns_write_rr_soa:
  354|    715|{
  355|    715|  ares_status_t status;
  356|       |
  357|       |  /* MNAME */
  358|    715|  status =
  359|    715|    ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE, ARES_RR_SOA_MNAME);
  360|    715|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (360:7): [True: 45, False: 670]
  ------------------
  361|     45|    return status;
  362|     45|  }
  363|       |
  364|       |  /* RNAME */
  365|    670|  status =
  366|    670|    ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE, ARES_RR_SOA_RNAME);
  367|    670|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (367:7): [True: 11, False: 659]
  ------------------
  368|     11|    return status;
  369|     11|  }
  370|       |
  371|       |  /* SERIAL */
  372|    659|  status = ares_dns_write_rr_be32(buf, rr, ARES_RR_SOA_SERIAL);
  373|    659|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (373:7): [True: 0, False: 659]
  ------------------
  374|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  375|      0|  }
  376|       |
  377|       |  /* REFRESH */
  378|    659|  status = ares_dns_write_rr_be32(buf, rr, ARES_RR_SOA_REFRESH);
  379|    659|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (379:7): [True: 0, False: 659]
  ------------------
  380|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  381|      0|  }
  382|       |
  383|       |  /* RETRY */
  384|    659|  status = ares_dns_write_rr_be32(buf, rr, ARES_RR_SOA_RETRY);
  385|    659|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (385:7): [True: 0, False: 659]
  ------------------
  386|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  387|      0|  }
  388|       |
  389|       |  /* EXPIRE */
  390|    659|  status = ares_dns_write_rr_be32(buf, rr, ARES_RR_SOA_EXPIRE);
  391|    659|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (391:7): [True: 0, False: 659]
  ------------------
  392|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  393|      0|  }
  394|       |
  395|       |  /* MINIMUM */
  396|    659|  return ares_dns_write_rr_be32(buf, rr, ARES_RR_SOA_MINIMUM);
  397|    659|}
ares_dns_write.c:ares_dns_write_rr_be32:
  293|  5.95k|{
  294|  5.95k|  if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_U32) {
  ------------------
  |  Branch (294:7): [True: 0, False: 5.95k]
  ------------------
  295|      0|    return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
  296|      0|  }
  297|  5.95k|  return ares_buf_append_be32(buf, ares_dns_rr_get_u32(rr, key));
  298|  5.95k|}
ares_dns_write.c:ares_dns_write_rr_ptr:
  402|    478|{
  403|    478|  return ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE,
  404|    478|                                ARES_RR_PTR_DNAME);
  405|    478|}
ares_dns_write.c:ares_dns_write_rr_hinfo:
  410|    718|{
  411|    718|  ares_status_t status;
  412|       |
  413|    718|  (void)namelist;
  414|       |
  415|       |  /* CPU */
  416|    718|  status = ares_dns_write_rr_str(buf, rr, ARES_RR_HINFO_CPU);
  417|    718|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (417:7): [True: 0, False: 718]
  ------------------
  418|      0|    return status;
  419|      0|  }
  420|       |
  421|       |  /* OS */
  422|    718|  return ares_dns_write_rr_str(buf, rr, ARES_RR_HINFO_OS);
  423|    718|}
ares_dns_write.c:ares_dns_write_rr_str:
  196|  4.23k|{
  197|  4.23k|  const char   *str;
  198|  4.23k|  size_t        len;
  199|  4.23k|  ares_status_t status;
  200|       |
  201|  4.23k|  str = ares_dns_rr_get_str(rr, key);
  202|  4.23k|  if (str == NULL) {
  ------------------
  |  Branch (202:7): [True: 0, False: 4.23k]
  ------------------
  203|      0|    return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
  204|      0|  }
  205|       |
  206|  4.23k|  len = ares_strlen(str);
  207|  4.23k|  if (len > 255) {
  ------------------
  |  Branch (207:7): [True: 0, False: 4.23k]
  ------------------
  208|      0|    return ARES_EFORMERR;
  209|      0|  }
  210|       |
  211|       |  /* Write 1 byte length */
  212|  4.23k|  status = ares_buf_append_byte(buf, (unsigned char)(len & 0xFF));
  213|  4.23k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (213:7): [True: 0, False: 4.23k]
  ------------------
  214|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  215|      0|  }
  216|       |
  217|  4.23k|  if (len == 0) {
  ------------------
  |  Branch (217:7): [True: 2.73k, False: 1.50k]
  ------------------
  218|  2.73k|    return ARES_SUCCESS;
  219|  2.73k|  }
  220|       |
  221|       |  /* Write string */
  222|  1.50k|  return ares_buf_append(buf, (const unsigned char *)str, len);
  223|  4.23k|}
ares_dns_write.c:ares_dns_write_rr_mx:
  428|    411|{
  429|    411|  ares_status_t status;
  430|       |
  431|       |  /* PREFERENCE */
  432|    411|  status = ares_dns_write_rr_be16(buf, rr, ARES_RR_MX_PREFERENCE);
  433|    411|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (433:7): [True: 0, False: 411]
  ------------------
  434|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  435|      0|  }
  436|       |
  437|       |  /* EXCHANGE */
  438|    411|  return ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE,
  439|    411|                                ARES_RR_MX_EXCHANGE);
  440|    411|}
ares_dns_write.c:ares_dns_write_rr_be16:
  303|  11.1k|{
  304|  11.1k|  if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_U16) {
  ------------------
  |  Branch (304:7): [True: 0, False: 11.1k]
  ------------------
  305|      0|    return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
  306|      0|  }
  307|  11.1k|  return ares_buf_append_be16(buf, ares_dns_rr_get_u16(rr, key));
  308|  11.1k|}
ares_dns_write.c:ares_dns_write_rr_txt:
  445|    972|{
  446|    972|  (void)namelist;
  447|    972|  return ares_dns_write_rr_abin(buf, rr, ARES_RR_TXT_DATA);
  448|    972|}
ares_dns_write.c:ares_dns_write_rr_abin:
  266|    972|{
  267|    972|  ares_status_t status = ARES_EFORMERR;
  268|    972|  size_t        i;
  269|    972|  size_t        cnt = ares_dns_rr_get_abin_cnt(rr, key);
  270|       |
  271|    972|  if (cnt == 0) {
  ------------------
  |  Branch (271:7): [True: 0, False: 972]
  ------------------
  272|      0|    return ARES_EFORMERR;
  273|      0|  }
  274|       |
  275|  84.4k|  for (i = 0; i < cnt; i++) {
  ------------------
  |  Branch (275:15): [True: 83.4k, False: 972]
  ------------------
  276|  83.4k|    const unsigned char *bin;
  277|  83.4k|    size_t               bin_len;
  278|       |
  279|  83.4k|    bin = ares_dns_rr_get_abin(rr, key, i, &bin_len);
  280|       |
  281|  83.4k|    status = ares_dns_write_binstr(buf, bin, bin_len);
  282|  83.4k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (282:9): [True: 0, False: 83.4k]
  ------------------
  283|      0|      break;
  284|      0|    }
  285|  83.4k|  }
  286|       |
  287|    972|  return status;
  288|    972|}
ares_dns_write.c:ares_dns_write_binstr:
  228|  83.4k|{
  229|  83.4k|  const unsigned char *ptr;
  230|  83.4k|  size_t               ptr_len;
  231|  83.4k|  ares_status_t        status;
  232|       |
  233|       |  /* split into possible multiple 255-byte or less length strings */
  234|  83.4k|  ptr     = bin;
  235|  83.4k|  ptr_len = bin_len;
  236|  83.4k|  do {
  237|  83.4k|    size_t len = ptr_len;
  238|  83.4k|    if (len > 255) {
  ------------------
  |  Branch (238:9): [True: 0, False: 83.4k]
  ------------------
  239|      0|      len = 255;
  240|      0|    }
  241|       |
  242|       |    /* Length */
  243|  83.4k|    status = ares_buf_append_byte(buf, (unsigned char)(len & 0xFF));
  244|  83.4k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (244:9): [True: 0, False: 83.4k]
  ------------------
  245|      0|      return status; /* LCOV_EXCL_LINE: OutOfMemory */
  246|      0|    }
  247|       |
  248|       |    /* String */
  249|  83.4k|    if (len) {
  ------------------
  |  Branch (249:9): [True: 1.79k, False: 81.6k]
  ------------------
  250|  1.79k|      status = ares_buf_append(buf, ptr, len);
  251|  1.79k|      if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (251:11): [True: 0, False: 1.79k]
  ------------------
  252|      0|        return status; /* LCOV_EXCL_LINE: OutOfMemory */
  253|      0|      }
  254|  1.79k|    }
  255|       |
  256|  83.4k|    ptr     += len;
  257|  83.4k|    ptr_len -= len;
  258|  83.4k|  } while (ptr_len > 0);
  ------------------
  |  Branch (258:12): [True: 0, False: 83.4k]
  ------------------
  259|       |
  260|  83.4k|  return ARES_SUCCESS;
  261|  83.4k|}
ares_dns_write.c:ares_dns_write_rr_sig:
  453|    888|{
  454|    888|  ares_status_t        status;
  455|    888|  const unsigned char *data;
  456|    888|  size_t               len = 0;
  457|       |
  458|    888|  (void)namelist;
  459|       |
  460|       |  /* TYPE COVERED */
  461|    888|  status = ares_dns_write_rr_be16(buf, rr, ARES_RR_SIG_TYPE_COVERED);
  462|    888|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (462:7): [True: 0, False: 888]
  ------------------
  463|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  464|      0|  }
  465|       |
  466|       |  /* ALGORITHM */
  467|    888|  status = ares_dns_write_rr_u8(buf, rr, ARES_RR_SIG_ALGORITHM);
  468|    888|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (468:7): [True: 0, False: 888]
  ------------------
  469|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  470|      0|  }
  471|       |
  472|       |  /* LABELS */
  473|    888|  status = ares_dns_write_rr_u8(buf, rr, ARES_RR_SIG_LABELS);
  474|    888|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (474:7): [True: 0, False: 888]
  ------------------
  475|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  476|      0|  }
  477|       |
  478|       |  /* ORIGINAL TTL */
  479|    888|  status = ares_dns_write_rr_be32(buf, rr, ARES_RR_SIG_ORIGINAL_TTL);
  480|    888|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (480:7): [True: 0, False: 888]
  ------------------
  481|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  482|      0|  }
  483|       |
  484|       |  /* EXPIRATION */
  485|    888|  status = ares_dns_write_rr_be32(buf, rr, ARES_RR_SIG_EXPIRATION);
  486|    888|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (486:7): [True: 0, False: 888]
  ------------------
  487|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  488|      0|  }
  489|       |
  490|       |  /* INCEPTION */
  491|    888|  status = ares_dns_write_rr_be32(buf, rr, ARES_RR_SIG_INCEPTION);
  492|    888|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (492:7): [True: 0, False: 888]
  ------------------
  493|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  494|      0|  }
  495|       |
  496|       |  /* KEY TAG */
  497|    888|  status = ares_dns_write_rr_be16(buf, rr, ARES_RR_SIG_KEY_TAG);
  498|    888|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (498:7): [True: 0, False: 888]
  ------------------
  499|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  500|      0|  }
  501|       |
  502|       |  /* SIGNERS NAME */
  503|    888|  status = ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE,
  504|    888|                                  ARES_RR_SIG_SIGNERS_NAME);
  505|    888|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (505:7): [True: 3, False: 885]
  ------------------
  506|      3|    return status;
  507|      3|  }
  508|       |
  509|       |  /* SIGNATURE -- binary, rest of buffer, required to be non-zero length */
  510|    885|  data = ares_dns_rr_get_bin(rr, ARES_RR_SIG_SIGNATURE, &len);
  511|    885|  if (data == NULL || len == 0) {
  ------------------
  |  Branch (511:7): [True: 0, False: 885]
  |  Branch (511:23): [True: 0, False: 885]
  ------------------
  512|      0|    return ARES_EFORMERR;
  513|      0|  }
  514|       |
  515|    885|  return ares_buf_append(buf, data, len);
  516|    885|}
ares_dns_write.c:ares_dns_write_rr_u8:
  313|  4.03k|{
  314|  4.03k|  if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_U8) {
  ------------------
  |  Branch (314:7): [True: 0, False: 4.03k]
  ------------------
  315|      0|    return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
  316|      0|  }
  317|  4.03k|  return ares_buf_append_byte(buf, ares_dns_rr_get_u8(rr, key));
  318|  4.03k|}
ares_dns_write.c:ares_dns_write_rr_aaaa:
  521|  1.03k|{
  522|  1.03k|  const struct ares_in6_addr *addr;
  523|  1.03k|  (void)namelist;
  524|       |
  525|  1.03k|  addr = ares_dns_rr_get_addr6(rr, ARES_RR_AAAA_ADDR);
  526|  1.03k|  if (addr == NULL) {
  ------------------
  |  Branch (526:7): [True: 0, False: 1.03k]
  ------------------
  527|      0|    return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
  528|      0|  }
  529|       |
  530|  1.03k|  return ares_buf_append(buf, (const unsigned char *)addr, sizeof(*addr));
  531|  1.03k|}
ares_dns_write.c:ares_dns_write_rr_srv:
  536|    416|{
  537|    416|  ares_status_t status;
  538|       |
  539|       |  /* PRIORITY */
  540|    416|  status = ares_dns_write_rr_be16(buf, rr, ARES_RR_SRV_PRIORITY);
  541|    416|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (541:7): [True: 0, False: 416]
  ------------------
  542|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  543|      0|  }
  544|       |
  545|       |  /* WEIGHT */
  546|    416|  status = ares_dns_write_rr_be16(buf, rr, ARES_RR_SRV_WEIGHT);
  547|    416|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (547:7): [True: 0, False: 416]
  ------------------
  548|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  549|      0|  }
  550|       |
  551|       |  /* PORT */
  552|    416|  status = ares_dns_write_rr_be16(buf, rr, ARES_RR_SRV_PORT);
  553|    416|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (553:7): [True: 0, False: 416]
  ------------------
  554|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  555|      0|  }
  556|       |
  557|       |  /* TARGET */
  558|    416|  return ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE,
  559|    416|                                ARES_RR_SRV_TARGET);
  560|    416|}
ares_dns_write.c:ares_dns_write_rr_naptr:
  565|    758|{
  566|    758|  ares_status_t status;
  567|       |
  568|       |  /* ORDER */
  569|    758|  status = ares_dns_write_rr_be16(buf, rr, ARES_RR_NAPTR_ORDER);
  570|    758|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (570:7): [True: 0, False: 758]
  ------------------
  571|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  572|      0|  }
  573|       |
  574|       |  /* PREFERENCE */
  575|    758|  status = ares_dns_write_rr_be16(buf, rr, ARES_RR_NAPTR_PREFERENCE);
  576|    758|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (576:7): [True: 0, False: 758]
  ------------------
  577|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  578|      0|  }
  579|       |
  580|       |  /* FLAGS */
  581|    758|  status = ares_dns_write_rr_str(buf, rr, ARES_RR_NAPTR_FLAGS);
  582|    758|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (582:7): [True: 0, False: 758]
  ------------------
  583|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  584|      0|  }
  585|       |
  586|       |  /* SERVICES */
  587|    758|  status = ares_dns_write_rr_str(buf, rr, ARES_RR_NAPTR_SERVICES);
  588|    758|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (588:7): [True: 0, False: 758]
  ------------------
  589|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  590|      0|  }
  591|       |
  592|       |  /* REGEXP */
  593|    758|  status = ares_dns_write_rr_str(buf, rr, ARES_RR_NAPTR_REGEXP);
  594|    758|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (594:7): [True: 0, False: 758]
  ------------------
  595|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  596|      0|  }
  597|       |
  598|       |  /* REPLACEMENT */
  599|    758|  return ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE,
  600|    758|                                ARES_RR_NAPTR_REPLACEMENT);
  601|    758|}
ares_dns_write.c:ares_dns_write_rr_opt:
  606|  2.18k|{
  607|  2.18k|  size_t         len = ares_buf_len(buf);
  608|  2.18k|  ares_status_t  status;
  609|  2.18k|  unsigned int   ttl = 0;
  610|  2.18k|  size_t         i;
  611|  2.18k|  unsigned short rcode = (unsigned short)((rr->parent->rcode >> 4) & 0xFF);
  612|       |
  613|  2.18k|  (void)namelist;
  614|       |
  615|       |  /* Coverity reports on this even though its not possible when taken
  616|       |   * into context */
  617|  2.18k|  if (len == 0) {
  ------------------
  |  Branch (617:7): [True: 0, False: 2.18k]
  ------------------
  618|      0|    return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
  619|      0|  }
  620|       |
  621|       |  /* We need to go back and overwrite the class and ttl that were emitted as
  622|       |   * the OPT record overloads them for its own use (yes, very strange!) */
  623|  2.18k|  status = ares_buf_set_length(buf, len - 2 /* RDLENGTH */
  624|  2.18k|                                      - 4   /* TTL */
  625|  2.18k|                                      - 2 /* CLASS */);
  626|  2.18k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (626:7): [True: 0, False: 2.18k]
  ------------------
  627|      0|    return status;
  628|      0|  }
  629|       |
  630|       |  /* Class -> UDP Size */
  631|  2.18k|  status = ares_dns_write_rr_be16(buf, rr, ARES_RR_OPT_UDP_SIZE);
  632|  2.18k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (632:7): [True: 0, False: 2.18k]
  ------------------
  633|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  634|      0|  }
  635|       |
  636|       |  /* TTL -> rcode (u8) << 24 | version (u8) << 16 | flags (u16) */
  637|  2.18k|  ttl |= (unsigned int)rcode << 24;
  638|  2.18k|  ttl |= (unsigned int)ares_dns_rr_get_u8(rr, ARES_RR_OPT_VERSION) << 16;
  639|  2.18k|  ttl |= (unsigned int)ares_dns_rr_get_u16(rr, ARES_RR_OPT_FLAGS);
  640|       |
  641|  2.18k|  status = ares_buf_append_be32(buf, ttl);
  642|  2.18k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (642:7): [True: 0, False: 2.18k]
  ------------------
  643|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  644|      0|  }
  645|       |
  646|       |  /* Now go back to real end */
  647|  2.18k|  status = ares_buf_set_length(buf, len);
  648|  2.18k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (648:7): [True: 0, False: 2.18k]
  ------------------
  649|      0|    return status;
  650|      0|  }
  651|       |
  652|       |  /* Append Options */
  653|  2.98k|  for (i = 0; i < ares_dns_rr_get_opt_cnt(rr, ARES_RR_OPT_OPTIONS); i++) {
  ------------------
  |  Branch (653:15): [True: 799, False: 2.18k]
  ------------------
  654|    799|    unsigned short       opt;
  655|    799|    size_t               val_len;
  656|    799|    const unsigned char *val;
  657|       |
  658|    799|    opt = ares_dns_rr_get_opt(rr, ARES_RR_OPT_OPTIONS, i, &val, &val_len);
  659|       |
  660|       |    /* BE16 option */
  661|    799|    status = ares_buf_append_be16(buf, opt);
  662|    799|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (662:9): [True: 0, False: 799]
  ------------------
  663|      0|      return status; /* LCOV_EXCL_LINE: OutOfMemory */
  664|      0|    }
  665|       |
  666|       |    /* BE16 length */
  667|    799|    status = ares_buf_append_be16(buf, (unsigned short)(val_len & 0xFFFF));
  668|    799|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (668:9): [True: 0, False: 799]
  ------------------
  669|      0|      return status; /* LCOV_EXCL_LINE: OutOfMemory */
  670|      0|    }
  671|       |
  672|       |    /* Value */
  673|    799|    if (val && val_len) {
  ------------------
  |  Branch (673:9): [True: 142, False: 657]
  |  Branch (673:16): [True: 142, False: 0]
  ------------------
  674|    142|      status = ares_buf_append(buf, val, val_len);
  675|    142|      if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (675:11): [True: 0, False: 142]
  ------------------
  676|      0|        return status; /* LCOV_EXCL_LINE: OutOfMemory */
  677|      0|      }
  678|    142|    }
  679|    799|  }
  680|       |
  681|  2.18k|  return ARES_SUCCESS;
  682|  2.18k|}
ares_dns_write.c:ares_dns_write_rr_tlsa:
  687|    578|{
  688|    578|  ares_status_t        status;
  689|    578|  const unsigned char *data;
  690|    578|  size_t               len = 0;
  691|       |
  692|    578|  (void)namelist;
  693|       |
  694|       |  /* CERT_USAGE */
  695|    578|  status = ares_dns_write_rr_u8(buf, rr, ARES_RR_TLSA_CERT_USAGE);
  696|    578|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (696:7): [True: 0, False: 578]
  ------------------
  697|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  698|      0|  }
  699|       |
  700|       |  /* SELECTOR */
  701|    578|  status = ares_dns_write_rr_u8(buf, rr, ARES_RR_TLSA_SELECTOR);
  702|    578|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (702:7): [True: 0, False: 578]
  ------------------
  703|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  704|      0|  }
  705|       |
  706|       |  /* MATCH */
  707|    578|  status = ares_dns_write_rr_u8(buf, rr, ARES_RR_TLSA_MATCH);
  708|    578|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (708:7): [True: 0, False: 578]
  ------------------
  709|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  710|      0|  }
  711|       |
  712|       |  /* DATA -- binary, rest of buffer, required to be non-zero length */
  713|    578|  data = ares_dns_rr_get_bin(rr, ARES_RR_TLSA_DATA, &len);
  714|    578|  if (data == NULL || len == 0) {
  ------------------
  |  Branch (714:7): [True: 0, False: 578]
  |  Branch (714:23): [True: 0, False: 578]
  ------------------
  715|      0|    return ARES_EFORMERR;
  716|      0|  }
  717|       |
  718|    578|  return ares_buf_append(buf, data, len);
  719|    578|}
ares_dns_write.c:ares_dns_write_rr_svcb:
  724|    812|{
  725|    812|  ares_status_t status;
  726|    812|  size_t        i;
  727|       |
  728|       |  /* PRIORITY */
  729|    812|  status = ares_dns_write_rr_be16(buf, rr, ARES_RR_SVCB_PRIORITY);
  730|    812|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (730:7): [True: 0, False: 812]
  ------------------
  731|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  732|      0|  }
  733|       |
  734|       |  /* TARGET */
  735|    812|  status =
  736|    812|    ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE, ARES_RR_SVCB_TARGET);
  737|    812|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (737:7): [True: 1, False: 811]
  ------------------
  738|      1|    return status;
  739|      1|  }
  740|       |
  741|       |  /* Append Params */
  742|  2.43k|  for (i = 0; i < ares_dns_rr_get_opt_cnt(rr, ARES_RR_SVCB_PARAMS); i++) {
  ------------------
  |  Branch (742:15): [True: 1.61k, False: 811]
  ------------------
  743|  1.61k|    unsigned short       opt;
  744|  1.61k|    size_t               val_len;
  745|  1.61k|    const unsigned char *val;
  746|       |
  747|  1.61k|    opt = ares_dns_rr_get_opt(rr, ARES_RR_SVCB_PARAMS, i, &val, &val_len);
  748|       |
  749|       |    /* BE16 option */
  750|  1.61k|    status = ares_buf_append_be16(buf, opt);
  751|  1.61k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (751:9): [True: 0, False: 1.61k]
  ------------------
  752|      0|      return status; /* LCOV_EXCL_LINE: OutOfMemory */
  753|      0|    }
  754|       |
  755|       |    /* BE16 length */
  756|  1.61k|    status = ares_buf_append_be16(buf, (unsigned short)(val_len & 0xFFFF));
  757|  1.61k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (757:9): [True: 0, False: 1.61k]
  ------------------
  758|      0|      return status; /* LCOV_EXCL_LINE: OutOfMemory */
  759|      0|    }
  760|       |
  761|       |    /* Value */
  762|  1.61k|    if (val && val_len) {
  ------------------
  |  Branch (762:9): [True: 707, False: 912]
  |  Branch (762:16): [True: 707, False: 0]
  ------------------
  763|    707|      status = ares_buf_append(buf, val, val_len);
  764|    707|      if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (764:11): [True: 0, False: 707]
  ------------------
  765|      0|        return status; /* LCOV_EXCL_LINE: OutOfMemory */
  766|      0|      }
  767|    707|    }
  768|  1.61k|  }
  769|    811|  return ARES_SUCCESS;
  770|    811|}
ares_dns_write.c:ares_dns_write_rr_https:
  775|    725|{
  776|    725|  ares_status_t status;
  777|    725|  size_t        i;
  778|       |
  779|       |  /* PRIORITY */
  780|    725|  status = ares_dns_write_rr_be16(buf, rr, ARES_RR_HTTPS_PRIORITY);
  781|    725|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (781:7): [True: 0, False: 725]
  ------------------
  782|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  783|      0|  }
  784|       |
  785|       |  /* TARGET */
  786|    725|  status =
  787|    725|    ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE, ARES_RR_HTTPS_TARGET);
  788|    725|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (788:7): [True: 1, False: 724]
  ------------------
  789|      1|    return status;
  790|      1|  }
  791|       |
  792|       |  /* Append Params */
  793|  2.28k|  for (i = 0; i < ares_dns_rr_get_opt_cnt(rr, ARES_RR_HTTPS_PARAMS); i++) {
  ------------------
  |  Branch (793:15): [True: 1.55k, False: 724]
  ------------------
  794|  1.55k|    unsigned short       opt;
  795|  1.55k|    size_t               val_len;
  796|  1.55k|    const unsigned char *val;
  797|       |
  798|  1.55k|    opt = ares_dns_rr_get_opt(rr, ARES_RR_HTTPS_PARAMS, i, &val, &val_len);
  799|       |
  800|       |    /* BE16 option */
  801|  1.55k|    status = ares_buf_append_be16(buf, opt);
  802|  1.55k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (802:9): [True: 0, False: 1.55k]
  ------------------
  803|      0|      return status; /* LCOV_EXCL_LINE: OutOfMemory */
  804|      0|    }
  805|       |
  806|       |    /* BE16 length */
  807|  1.55k|    status = ares_buf_append_be16(buf, (unsigned short)(val_len & 0xFFFF));
  808|  1.55k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (808:9): [True: 0, False: 1.55k]
  ------------------
  809|      0|      return status; /* LCOV_EXCL_LINE: OutOfMemory */
  810|      0|    }
  811|       |
  812|       |    /* Value */
  813|  1.55k|    if (val && val_len) {
  ------------------
  |  Branch (813:9): [True: 673, False: 885]
  |  Branch (813:16): [True: 673, False: 0]
  ------------------
  814|    673|      status = ares_buf_append(buf, val, val_len);
  815|    673|      if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (815:11): [True: 0, False: 673]
  ------------------
  816|      0|        return status; /* LCOV_EXCL_LINE: OutOfMemory */
  817|      0|      }
  818|    673|    }
  819|  1.55k|  }
  820|    724|  return ARES_SUCCESS;
  821|    724|}
ares_dns_write.c:ares_dns_write_rr_uri:
  826|    417|{
  827|    417|  ares_status_t status;
  828|    417|  const char   *target;
  829|       |
  830|    417|  (void)namelist;
  831|       |
  832|       |  /* PRIORITY */
  833|    417|  status = ares_dns_write_rr_be16(buf, rr, ARES_RR_URI_PRIORITY);
  834|    417|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (834:7): [True: 0, False: 417]
  ------------------
  835|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  836|      0|  }
  837|       |
  838|       |  /* WEIGHT */
  839|    417|  status = ares_dns_write_rr_be16(buf, rr, ARES_RR_URI_WEIGHT);
  840|    417|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (840:7): [True: 0, False: 417]
  ------------------
  841|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  842|      0|  }
  843|       |
  844|       |  /* TARGET -- not in DNS string format, rest of buffer, required to be
  845|       |   * non-zero length */
  846|    417|  target = ares_dns_rr_get_str(rr, ARES_RR_URI_TARGET);
  847|    417|  if (target == NULL || ares_strlen(target) == 0) {
  ------------------
  |  Branch (847:7): [True: 0, False: 417]
  |  Branch (847:25): [True: 0, False: 417]
  ------------------
  848|      0|    return ARES_EFORMERR;
  849|      0|  }
  850|       |
  851|    417|  return ares_buf_append(buf, (const unsigned char *)target,
  852|    417|                         ares_strlen(target));
  853|    417|}
ares_dns_write.c:ares_dns_write_rr_caa:
  858|    525|{
  859|    525|  const unsigned char *data     = NULL;
  860|    525|  size_t               data_len = 0;
  861|    525|  ares_status_t        status;
  862|       |
  863|    525|  (void)namelist;
  864|       |
  865|       |  /* CRITICAL */
  866|    525|  status = ares_dns_write_rr_u8(buf, rr, ARES_RR_CAA_CRITICAL);
  867|    525|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (867:7): [True: 0, False: 525]
  ------------------
  868|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  869|      0|  }
  870|       |
  871|       |  /* Tag */
  872|    525|  status = ares_dns_write_rr_str(buf, rr, ARES_RR_CAA_TAG);
  873|    525|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (873:7): [True: 0, False: 525]
  ------------------
  874|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  875|      0|  }
  876|       |
  877|       |  /* Value - binary! (remaining buffer */
  878|    525|  data = ares_dns_rr_get_bin(rr, ARES_RR_CAA_VALUE, &data_len);
  879|    525|  if (data == NULL || data_len == 0) {
  ------------------
  |  Branch (879:7): [True: 0, False: 525]
  |  Branch (879:23): [True: 0, False: 525]
  ------------------
  880|      0|    return ARES_EFORMERR;
  881|      0|  }
  882|       |
  883|    525|  return ares_buf_append(buf, data, data_len);
  884|    525|}
ares_dns_write.c:ares_dns_write_rr_raw_rr:
  889|  1.68k|{
  890|  1.68k|  size_t               len = ares_buf_len(buf);
  891|  1.68k|  ares_status_t        status;
  892|  1.68k|  const unsigned char *data     = NULL;
  893|  1.68k|  size_t               data_len = 0;
  894|       |
  895|  1.68k|  (void)namelist;
  896|       |
  897|       |  /* Coverity reports on this even though its not possible when taken
  898|       |   * into context */
  899|  1.68k|  if (len == 0) {
  ------------------
  |  Branch (899:7): [True: 0, False: 1.68k]
  ------------------
  900|      0|    return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
  901|      0|  }
  902|       |
  903|       |  /* We need to go back and overwrite the type that was emitted by the parent
  904|       |   * function */
  905|  1.68k|  status = ares_buf_set_length(buf, len - 2 /* RDLENGTH */
  906|  1.68k|                                      - 4   /* TTL */
  907|  1.68k|                                      - 2   /* CLASS */
  908|  1.68k|                                      - 2 /* TYPE */);
  909|  1.68k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (909:7): [True: 0, False: 1.68k]
  ------------------
  910|      0|    return status;
  911|      0|  }
  912|       |
  913|  1.68k|  status = ares_dns_write_rr_be16(buf, rr, ARES_RR_RAW_RR_TYPE);
  914|  1.68k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (914:7): [True: 0, False: 1.68k]
  ------------------
  915|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  916|      0|  }
  917|       |
  918|       |  /* Now go back to real end */
  919|  1.68k|  status = ares_buf_set_length(buf, len);
  920|  1.68k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (920:7): [True: 0, False: 1.68k]
  ------------------
  921|      0|    return status;
  922|      0|  }
  923|       |
  924|       |  /* Output raw data */
  925|  1.68k|  data = ares_dns_rr_get_bin(rr, ARES_RR_RAW_RR_DATA, &data_len);
  926|  1.68k|  if (data == NULL) {
  ------------------
  |  Branch (926:7): [True: 349, False: 1.33k]
  ------------------
  927|    349|    return ARES_EFORMERR;
  928|    349|  }
  929|       |
  930|  1.33k|  if (data_len == 0) {
  ------------------
  |  Branch (930:7): [True: 0, False: 1.33k]
  ------------------
  931|      0|    return ARES_SUCCESS;
  932|      0|  }
  933|       |
  934|  1.33k|  return ares_buf_append(buf, data, data_len);
  935|  1.33k|}

ares_buf_create:
   47|   151k|{
   48|   151k|  ares_buf_t *buf = ares_malloc_zero(sizeof(*buf));
   49|   151k|  if (buf == NULL) {
  ------------------
  |  Branch (49:7): [True: 0, False: 151k]
  ------------------
   50|      0|    return NULL;
   51|      0|  }
   52|       |
   53|   151k|  buf->tag_offset = SIZE_MAX;
   54|   151k|  return buf;
   55|   151k|}
ares_buf_create_const:
   58|  3.39k|{
   59|  3.39k|  ares_buf_t *buf;
   60|       |
   61|  3.39k|  if (data == NULL || data_len == 0) {
  ------------------
  |  Branch (61:7): [True: 0, False: 3.39k]
  |  Branch (61:23): [True: 0, False: 3.39k]
  ------------------
   62|      0|    return NULL;
   63|      0|  }
   64|       |
   65|  3.39k|  buf = ares_buf_create();
   66|  3.39k|  if (buf == NULL) {
  ------------------
  |  Branch (66:7): [True: 0, False: 3.39k]
  ------------------
   67|      0|    return NULL;
   68|      0|  }
   69|       |
   70|  3.39k|  buf->data     = data;
   71|  3.39k|  buf->data_len = data_len;
   72|       |
   73|  3.39k|  return buf;
   74|  3.39k|}
ares_buf_destroy:
   77|  63.9k|{
   78|  63.9k|  if (buf == NULL) {
  ------------------
  |  Branch (78:7): [True: 3.39k, False: 60.5k]
  ------------------
   79|  3.39k|    return;
   80|  3.39k|  }
   81|  60.5k|  ares_free(buf->alloc_buf);
   82|  60.5k|  ares_free(buf);
   83|  60.5k|}
ares_buf_reclaim:
   99|   269k|{
  100|   269k|  size_t prefix_size;
  101|   269k|  size_t data_size;
  102|       |
  103|   269k|  if (buf == NULL) {
  ------------------
  |  Branch (103:7): [True: 0, False: 269k]
  ------------------
  104|      0|    return;
  105|      0|  }
  106|       |
  107|   269k|  if (ares_buf_is_const(buf)) {
  ------------------
  |  Branch (107:7): [True: 0, False: 269k]
  ------------------
  108|      0|    return; /* LCOV_EXCL_LINE: DefensiveCoding */
  109|      0|  }
  110|       |
  111|       |  /* Silence coverity.  All lengths are zero so would bail out later but
  112|       |   * coverity doesn't know this */
  113|   269k|  if (buf->alloc_buf == NULL) {
  ------------------
  |  Branch (113:7): [True: 177k, False: 92.0k]
  ------------------
  114|   177k|    return;
  115|   177k|  }
  116|       |
  117|  92.0k|  if (buf->tag_offset != SIZE_MAX && buf->tag_offset < buf->offset) {
  ------------------
  |  Branch (117:7): [True: 0, False: 92.0k]
  |  Branch (117:38): [True: 0, False: 0]
  ------------------
  118|      0|    prefix_size = buf->tag_offset;
  119|  92.0k|  } else {
  120|  92.0k|    prefix_size = buf->offset;
  121|  92.0k|  }
  122|       |
  123|  92.0k|  if (prefix_size == 0) {
  ------------------
  |  Branch (123:7): [True: 92.0k, False: 0]
  ------------------
  124|  92.0k|    return;
  125|  92.0k|  }
  126|       |
  127|      0|  data_size = buf->data_len - prefix_size;
  128|       |
  129|      0|  memmove(buf->alloc_buf, buf->alloc_buf + prefix_size, data_size);
  130|      0|  buf->data      = buf->alloc_buf;
  131|      0|  buf->data_len  = data_size;
  132|      0|  buf->offset   -= prefix_size;
  133|      0|  if (buf->tag_offset != SIZE_MAX) {
  ------------------
  |  Branch (133:7): [True: 0, False: 0]
  ------------------
  134|      0|    buf->tag_offset -= prefix_size;
  135|      0|  }
  136|      0|}
ares_buf_set_length:
  203|  39.2k|{
  204|  39.2k|  if (buf == NULL || ares_buf_is_const(buf)) {
  ------------------
  |  Branch (204:7): [True: 0, False: 39.2k]
  |  Branch (204:22): [True: 0, False: 39.2k]
  ------------------
  205|      0|    return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
  206|      0|  }
  207|       |
  208|  39.2k|  if (len >= buf->alloc_buf_len - buf->offset) {
  ------------------
  |  Branch (208:7): [True: 0, False: 39.2k]
  ------------------
  209|      0|    return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
  210|      0|  }
  211|       |
  212|  39.2k|  buf->data_len = len + buf->offset;
  213|  39.2k|  return ARES_SUCCESS;
  214|  39.2k|}
ares_buf_append:
  218|  79.2M|{
  219|  79.2M|  ares_status_t status;
  220|       |
  221|  79.2M|  if (data == NULL && data_len != 0) {
  ------------------
  |  Branch (221:7): [True: 0, False: 79.2M]
  |  Branch (221:23): [True: 0, False: 0]
  ------------------
  222|      0|    return ARES_EFORMERR;
  223|      0|  }
  224|       |
  225|  79.2M|  if (data_len == 0) {
  ------------------
  |  Branch (225:7): [True: 199k, False: 79.0M]
  ------------------
  226|   199k|    return ARES_SUCCESS;
  227|   199k|  }
  228|       |
  229|  79.0M|  status = ares_buf_ensure_space(buf, data_len);
  230|  79.0M|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (230:7): [True: 0, False: 79.0M]
  ------------------
  231|      0|    return status;
  232|      0|  }
  233|       |
  234|  79.0M|  memcpy(buf->alloc_buf + buf->data_len, data, data_len);
  235|  79.0M|  buf->data_len += data_len;
  236|  79.0M|  return ARES_SUCCESS;
  237|  79.0M|}
ares_buf_append_byte:
  240|  5.68M|{
  241|  5.68M|  return ares_buf_append(buf, &b, 1);
  242|  5.68M|}
ares_buf_append_be16:
  245|  97.5k|{
  246|  97.5k|  ares_status_t status;
  247|       |
  248|  97.5k|  status = ares_buf_append_byte(buf, (unsigned char)((u16 >> 8) & 0xff));
  249|  97.5k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (249:7): [True: 0, False: 97.5k]
  ------------------
  250|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  251|      0|  }
  252|       |
  253|  97.5k|  status = ares_buf_append_byte(buf, (unsigned char)(u16 & 0xff));
  254|  97.5k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (254:7): [True: 0, False: 97.5k]
  ------------------
  255|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  256|      0|  }
  257|       |
  258|  97.5k|  return ARES_SUCCESS;
  259|  97.5k|}
ares_buf_append_be32:
  262|  23.9k|{
  263|  23.9k|  ares_status_t status;
  264|       |
  265|  23.9k|  status = ares_buf_append_byte(buf, ((unsigned char)(u32 >> 24) & 0xff));
  266|  23.9k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (266:7): [True: 0, False: 23.9k]
  ------------------
  267|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  268|      0|  }
  269|       |
  270|  23.9k|  status = ares_buf_append_byte(buf, ((unsigned char)(u32 >> 16) & 0xff));
  271|  23.9k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (271:7): [True: 0, False: 23.9k]
  ------------------
  272|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  273|      0|  }
  274|       |
  275|  23.9k|  status = ares_buf_append_byte(buf, ((unsigned char)(u32 >> 8) & 0xff));
  276|  23.9k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (276:7): [True: 0, False: 23.9k]
  ------------------
  277|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  278|      0|  }
  279|       |
  280|  23.9k|  status = ares_buf_append_byte(buf, ((unsigned char)u32 & 0xff));
  281|  23.9k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (281:7): [True: 0, False: 23.9k]
  ------------------
  282|      0|    return status; /* LCOV_EXCL_LINE: OutOfMemory */
  283|      0|  }
  284|       |
  285|  23.9k|  return ARES_SUCCESS;
  286|  23.9k|}
ares_buf_finish_bin:
  316|  90.8k|{
  317|  90.8k|  unsigned char *ptr = NULL;
  318|  90.8k|  if (buf == NULL || len == NULL || ares_buf_is_const(buf)) {
  ------------------
  |  Branch (318:7): [True: 0, False: 90.8k]
  |  Branch (318:22): [True: 0, False: 90.8k]
  |  Branch (318:37): [True: 0, False: 90.8k]
  ------------------
  319|      0|    return NULL;
  320|      0|  }
  321|       |
  322|  90.8k|  ares_buf_reclaim(buf);
  323|       |
  324|       |  /* We don't want to return NULL except on failure, may be zero-length */
  325|  90.8k|  if (buf->alloc_buf == NULL && ares_buf_ensure_space(buf, 1) != ARES_SUCCESS) {
  ------------------
  |  Branch (325:7): [True: 74.9k, False: 15.9k]
  |  Branch (325:33): [True: 0, False: 74.9k]
  ------------------
  326|      0|    return NULL; /* LCOV_EXCL_LINE: OutOfMemory */
  327|      0|  }
  328|  90.8k|  ptr  = buf->alloc_buf;
  329|  90.8k|  *len = buf->data_len;
  330|  90.8k|  ares_free(buf);
  331|  90.8k|  return ptr;
  332|  90.8k|}
ares_buf_finish_str:
  335|  89.8k|{
  336|  89.8k|  char  *ptr;
  337|  89.8k|  size_t mylen;
  338|       |
  339|  89.8k|  ptr = (char *)ares_buf_finish_bin(buf, &mylen);
  340|  89.8k|  if (ptr == NULL) {
  ------------------
  |  Branch (340:7): [True: 0, False: 89.8k]
  ------------------
  341|      0|    return NULL;
  342|      0|  }
  343|       |
  344|  89.8k|  if (len != NULL) {
  ------------------
  |  Branch (344:7): [True: 6.53k, False: 83.2k]
  ------------------
  345|  6.53k|    *len = mylen;
  346|  6.53k|  }
  347|       |
  348|       |  /* NOTE: ensured via ares_buf_ensure_space() that there is always at least
  349|       |   *       1 extra byte available for this specific use-case */
  350|  89.8k|  ptr[mylen] = 0;
  351|       |
  352|  89.8k|  return ptr;
  353|  89.8k|}
ares_buf_consume:
  518|  8.24M|{
  519|  8.24M|  size_t remaining_len = ares_buf_len(buf);
  520|       |
  521|  8.24M|  if (remaining_len < len) {
  ------------------
  |  Branch (521:7): [True: 0, False: 8.24M]
  ------------------
  522|      0|    return ARES_EBADRESP;
  523|      0|  }
  524|       |
  525|  8.24M|  buf->offset += len;
  526|  8.24M|  return ARES_SUCCESS;
  527|  8.24M|}
ares_buf_fetch_be16:
  530|   252k|{
  531|   252k|  size_t               remaining_len;
  532|   252k|  const unsigned char *ptr = ares_buf_fetch(buf, &remaining_len);
  533|   252k|  unsigned int         u32;
  534|       |
  535|   252k|  if (buf == NULL || u16 == NULL || remaining_len < sizeof(*u16)) {
  ------------------
  |  Branch (535:7): [True: 0, False: 252k]
  |  Branch (535:22): [True: 0, False: 252k]
  |  Branch (535:37): [True: 103, False: 252k]
  ------------------
  536|    103|    return ARES_EBADRESP;
  537|    103|  }
  538|       |
  539|       |  /* Do math in an unsigned int in order to prevent warnings due to automatic
  540|       |   * conversion by the compiler from short to int during shifts */
  541|   252k|  u32  = ((unsigned int)(ptr[0]) << 8 | (unsigned int)ptr[1]);
  542|   252k|  *u16 = (unsigned short)(u32 & 0xFFFF);
  543|       |
  544|   252k|  return ares_buf_consume(buf, sizeof(*u16));
  545|   252k|}
ares_buf_fetch_be32:
  548|  73.9k|{
  549|  73.9k|  size_t               remaining_len;
  550|  73.9k|  const unsigned char *ptr = ares_buf_fetch(buf, &remaining_len);
  551|       |
  552|  73.9k|  if (buf == NULL || u32 == NULL || remaining_len < sizeof(*u32)) {
  ------------------
  |  Branch (552:7): [True: 0, False: 73.9k]
  |  Branch (552:22): [True: 0, False: 73.9k]
  |  Branch (552:37): [True: 12, False: 73.9k]
  ------------------
  553|     12|    return ARES_EBADRESP;
  554|     12|  }
  555|       |
  556|  73.9k|  *u32 = ((unsigned int)(ptr[0]) << 24 | (unsigned int)(ptr[1]) << 16 |
  557|  73.9k|          (unsigned int)(ptr[2]) << 8 | (unsigned int)(ptr[3]));
  558|       |
  559|  73.9k|  return ares_buf_consume(buf, sizeof(*u32));
  560|  73.9k|}
ares_buf_fetch_bytes:
  564|  4.22M|{
  565|  4.22M|  size_t               remaining_len;
  566|  4.22M|  const unsigned char *ptr = ares_buf_fetch(buf, &remaining_len);
  567|       |
  568|  4.22M|  if (buf == NULL || bytes == NULL || len == 0 || remaining_len < len) {
  ------------------
  |  Branch (568:7): [True: 0, False: 4.22M]
  |  Branch (568:22): [True: 0, False: 4.22M]
  |  Branch (568:39): [True: 0, False: 4.22M]
  |  Branch (568:51): [True: 24.4k, False: 4.19M]
  ------------------
  569|  24.4k|    return ARES_EBADRESP;
  570|  24.4k|  }
  571|       |
  572|  4.19M|  memcpy(bytes, ptr, len);
  573|  4.19M|  return ares_buf_consume(buf, len);
  574|  4.22M|}
ares_buf_fetch_bytes_dup:
  579|  16.5k|{
  580|  16.5k|  size_t               remaining_len;
  581|  16.5k|  const unsigned char *ptr = ares_buf_fetch(buf, &remaining_len);
  582|       |
  583|  16.5k|  if (buf == NULL || bytes == NULL || len == 0 || remaining_len < len) {
  ------------------
  |  Branch (583:7): [True: 0, False: 16.5k]
  |  Branch (583:22): [True: 0, False: 16.5k]
  |  Branch (583:39): [True: 0, False: 16.5k]
  |  Branch (583:51): [True: 28, False: 16.5k]
  ------------------
  584|     28|    return ARES_EBADRESP;
  585|     28|  }
  586|       |
  587|  16.5k|  *bytes = ares_malloc(null_term ? len + 1 : len);
  ------------------
  |  Branch (587:24): [True: 11.1k, False: 5.36k]
  ------------------
  588|  16.5k|  if (*bytes == NULL) {
  ------------------
  |  Branch (588:7): [True: 0, False: 16.5k]
  ------------------
  589|      0|    return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
  590|      0|  }
  591|       |
  592|  16.5k|  memcpy(*bytes, ptr, len);
  593|  16.5k|  if (null_term) {
  ------------------
  |  Branch (593:7): [True: 11.1k, False: 5.36k]
  ------------------
  594|  11.1k|    (*bytes)[len] = 0;
  595|  11.1k|  }
  596|  16.5k|  return ares_buf_consume(buf, len);
  597|  16.5k|}
ares_buf_fetch_str_dup:
  600|    851|{
  601|    851|  size_t               remaining_len;
  602|    851|  size_t               i;
  603|    851|  const unsigned char *ptr = ares_buf_fetch(buf, &remaining_len);
  604|       |
  605|    851|  if (buf == NULL || str == NULL || len == 0 || remaining_len < len) {
  ------------------
  |  Branch (605:7): [True: 0, False: 851]
  |  Branch (605:22): [True: 0, False: 851]
  |  Branch (605:37): [True: 0, False: 851]
  |  Branch (605:49): [True: 0, False: 851]
  ------------------
  606|      0|    return ARES_EBADRESP;
  607|      0|  }
  608|       |
  609|       |  /* Validate string is printable */
  610|  12.2k|  for (i = 0; i < len; i++) {
  ------------------
  |  Branch (610:15): [True: 11.4k, False: 826]
  ------------------
  611|  11.4k|    if (!ares_isprint(ptr[i])) {
  ------------------
  |  |  114|  11.4k|  (((unsigned char)(x)) >= 0x20 && ((unsigned char)(x)) <= 0x7E)
  |  |  ------------------
  |  |  |  Branch (114:4): [True: 11.4k, False: 18]
  |  |  |  Branch (114:36): [True: 11.4k, False: 7]
  |  |  ------------------
  ------------------
  612|     25|      return ARES_EBADSTR;
  613|     25|    }
  614|  11.4k|  }
  615|       |
  616|    826|  *str = ares_malloc(len + 1);
  617|    826|  if (*str == NULL) {
  ------------------
  |  Branch (617:7): [True: 0, False: 826]
  ------------------
  618|      0|    return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
  619|      0|  }
  620|       |
  621|    826|  memcpy(*str, ptr, len);
  622|    826|  (*str)[len] = 0;
  623|       |
  624|    826|  return ares_buf_consume(buf, len);
  625|    826|}
ares_buf_fetch_bytes_into_buf:
  629|  2.56k|{
  630|  2.56k|  size_t               remaining_len;
  631|  2.56k|  const unsigned char *ptr = ares_buf_fetch(buf, &remaining_len);
  632|  2.56k|  ares_status_t        status;
  633|       |
  634|  2.56k|  if (buf == NULL || dest == NULL || len == 0 || remaining_len < len) {
  ------------------
  |  Branch (634:7): [True: 0, False: 2.56k]
  |  Branch (634:22): [True: 0, False: 2.56k]
  |  Branch (634:38): [True: 0, False: 2.56k]
  |  Branch (634:50): [True: 0, False: 2.56k]
  ------------------
  635|      0|    return ARES_EBADRESP;
  636|      0|  }
  637|       |
  638|  2.56k|  status = ares_buf_append(dest, ptr, len);
  639|  2.56k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (639:7): [True: 0, False: 2.56k]
  ------------------
  640|      0|    return status;
  641|      0|  }
  642|       |
  643|  2.56k|  return ares_buf_consume(buf, len);
  644|  2.56k|}
ares_buf_len:
 1100|  12.4M|{
 1101|  12.4M|  if (buf == NULL) {
  ------------------
  |  Branch (1101:7): [True: 0, False: 12.4M]
  ------------------
 1102|      0|    return 0;
 1103|      0|  }
 1104|       |
 1105|  12.4M|  return buf->data_len - buf->offset;
 1106|  12.4M|}
ares_buf_peek:
 1109|  3.71M|{
 1110|  3.71M|  return ares_buf_fetch(buf, len);
 1111|  3.71M|}
ares_buf_get_position:
 1196|  3.90M|{
 1197|  3.90M|  if (buf == NULL) {
  ------------------
  |  Branch (1197:7): [True: 0, False: 3.90M]
  ------------------
 1198|      0|    return 0;
 1199|      0|  }
 1200|  3.90M|  return buf->offset;
 1201|  3.90M|}
ares_buf_set_position:
 1204|  26.2k|{
 1205|  26.2k|  if (buf == NULL) {
  ------------------
  |  Branch (1205:7): [True: 0, False: 26.2k]
  ------------------
 1206|      0|    return ARES_EFORMERR;
 1207|      0|  }
 1208|       |
 1209|  26.2k|  if (idx > buf->data_len) {
  ------------------
  |  Branch (1209:7): [True: 0, False: 26.2k]
  ------------------
 1210|      0|    return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
 1211|      0|  }
 1212|       |
 1213|  26.2k|  buf->offset = idx;
 1214|  26.2k|  return ARES_SUCCESS;
 1215|  26.2k|}
ares_buf_parse_dns_str:
 1294|  6.57k|{
 1295|  6.57k|  size_t len;
 1296|       |
 1297|  6.57k|  return ares_buf_parse_dns_binstr_int(buf, remaining_len,
 1298|  6.57k|                                       (unsigned char **)str, &len, ARES_TRUE);
 1299|  6.57k|}
ares_buf_append_num_dec:
 1302|   129k|{
 1303|   129k|  size_t i;
 1304|   129k|  size_t mod;
 1305|       |
 1306|   129k|  if (len == 0) {
  ------------------
  |  Branch (1306:7): [True: 129k, False: 0]
  ------------------
 1307|   129k|    len = ares_count_digits(num);
 1308|   129k|  }
 1309|       |
 1310|   129k|  mod = ares_pow(10, len);
 1311|       |
 1312|   540k|  for (i = len; i > 0; i--) {
  ------------------
  |  Branch (1312:17): [True: 410k, False: 129k]
  ------------------
 1313|   410k|    size_t        digit = (num % mod);
 1314|   410k|    ares_status_t status;
 1315|       |
 1316|   410k|    mod /= 10;
 1317|       |
 1318|       |    /* Silence coverity.  Shouldn't be possible since we calculate it above */
 1319|   410k|    if (mod == 0) {
  ------------------
  |  Branch (1319:9): [True: 0, False: 410k]
  ------------------
 1320|      0|      return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
 1321|      0|    }
 1322|       |
 1323|   410k|    digit  /= mod;
 1324|   410k|    status  = ares_buf_append_byte(buf, '0' + (unsigned char)(digit & 0xFF));
 1325|   410k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1325:9): [True: 0, False: 410k]
  ------------------
 1326|      0|      return status; /* LCOV_EXCL_LINE: OutOfMemory */
 1327|      0|    }
 1328|   410k|  }
 1329|   129k|  return ARES_SUCCESS;
 1330|   129k|}
ares_buf_append_num_hex:
 1333|  1.82k|{
 1334|  1.82k|  size_t                     i;
 1335|  1.82k|  static const unsigned char hexbytes[] = "0123456789ABCDEF";
 1336|       |
 1337|  1.82k|  if (len == 0) {
  ------------------
  |  Branch (1337:7): [True: 1.82k, False: 0]
  ------------------
 1338|  1.82k|    len = ares_count_hexdigits(num);
 1339|  1.82k|  }
 1340|       |
 1341|  4.80k|  for (i = len; i > 0; i--) {
  ------------------
  |  Branch (1341:17): [True: 2.98k, False: 1.82k]
  ------------------
 1342|  2.98k|    ares_status_t status;
 1343|  2.98k|    status = ares_buf_append_byte(buf, hexbytes[(num >> ((i - 1) * 4)) & 0xF]);
 1344|  2.98k|    if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1344:9): [True: 0, False: 2.98k]
  ------------------
 1345|      0|      return status; /* LCOV_EXCL_LINE: OutOfMemory */
 1346|      0|    }
 1347|  2.98k|  }
 1348|  1.82k|  return ARES_SUCCESS;
 1349|  1.82k|}
ares_buf_append_str:
 1352|  1.04M|{
 1353|  1.04M|  return ares_buf_append(buf, (const unsigned char *)str, ares_strlen(str));
 1354|  1.04M|}
ares_buf.c:ares_buf_is_const:
   86|  79.4M|{
   87|  79.4M|  if (buf == NULL) {
  ------------------
  |  Branch (87:7): [True: 0, False: 79.4M]
  ------------------
   88|      0|    return ARES_FALSE; /* LCOV_EXCL_LINE: DefensiveCoding */
   89|      0|  }
   90|       |
   91|  79.4M|  if (buf->data != NULL && buf->alloc_buf == NULL) {
  ------------------
  |  Branch (91:7): [True: 79.1M, False: 354k]
  |  Branch (91:28): [True: 0, False: 79.1M]
  ------------------
   92|      0|    return ARES_TRUE;
   93|      0|  }
   94|       |
   95|  79.4M|  return ARES_FALSE;
   96|  79.4M|}
ares_buf.c:ares_buf_ensure_space:
  139|  79.0M|{
  140|  79.0M|  size_t         remaining_size;
  141|  79.0M|  size_t         alloc_size;
  142|  79.0M|  unsigned char *ptr;
  143|       |
  144|  79.0M|  if (buf == NULL) {
  ------------------
  |  Branch (144:7): [True: 0, False: 79.0M]
  ------------------
  145|      0|    return ARES_EFORMERR;
  146|      0|  }
  147|       |
  148|  79.0M|  if (ares_buf_is_const(buf)) {
  ------------------
  |  Branch (148:7): [True: 0, False: 79.0M]
  ------------------
  149|      0|    return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
  150|      0|  }
  151|       |
  152|       |  /* When calling ares_buf_finish_str() we end up adding a null terminator,
  153|       |   * so we want to ensure the size is always sufficient for this as we don't
  154|       |   * want an ARES_ENOMEM at that point */
  155|  79.0M|  if (needed_size == SIZE_MAX) {
  ------------------
  |  Branch (155:7): [True: 0, False: 79.0M]
  ------------------
  156|      0|    return ARES_ENOMEM;
  157|      0|  }
  158|  79.0M|  needed_size++;
  159|       |
  160|       |  /* No need to do an expensive move operation, we have enough to just append */
  161|  79.0M|  remaining_size = buf->alloc_buf_len - buf->data_len;
  162|  79.0M|  if (remaining_size >= needed_size) {
  ------------------
  |  Branch (162:7): [True: 78.9M, False: 178k]
  ------------------
  163|  78.9M|    return ARES_SUCCESS;
  164|  78.9M|  }
  165|       |
  166|       |  /* See if just moving consumed data frees up enough space */
  167|   178k|  ares_buf_reclaim(buf);
  168|       |
  169|   178k|  remaining_size = buf->alloc_buf_len - buf->data_len;
  170|   178k|  if (remaining_size >= needed_size) {
  ------------------
  |  Branch (170:7): [True: 0, False: 178k]
  ------------------
  171|      0|    return ARES_SUCCESS;
  172|      0|  }
  173|       |
  174|   178k|  alloc_size = buf->alloc_buf_len;
  175|       |
  176|       |  /* Not yet started */
  177|   178k|  if (alloc_size == 0) {
  ------------------
  |  Branch (177:7): [True: 102k, False: 76.1k]
  ------------------
  178|   102k|    alloc_size = 16; /* Always shifts 1, so ends up being 32 minimum */
  179|   102k|  }
  180|       |
  181|       |  /* Increase allocation by powers of 2 */
  182|   181k|  do {
  183|   181k|    if (alloc_size > SIZE_MAX >> 1) {
  ------------------
  |  Branch (183:9): [True: 0, False: 181k]
  ------------------
  184|      0|      return ARES_ENOMEM;
  185|      0|    }
  186|   181k|    alloc_size     <<= 1;
  187|   181k|    remaining_size   = alloc_size - buf->data_len;
  188|   181k|  } while (remaining_size < needed_size);
  ------------------
  |  Branch (188:12): [True: 3.40k, False: 178k]
  ------------------
  189|       |
  190|   178k|  ptr = ares_realloc(buf->alloc_buf, alloc_size);
  191|   178k|  if (ptr == NULL) {
  ------------------
  |  Branch (191:7): [True: 0, False: 178k]
  ------------------
  192|      0|    return ARES_ENOMEM;
  193|      0|  }
  194|       |
  195|   178k|  buf->alloc_buf     = ptr;
  196|   178k|  buf->alloc_buf_len = alloc_size;
  197|   178k|  buf->data          = ptr;
  198|       |
  199|   178k|  return ARES_SUCCESS;
  200|   178k|}
ares_buf.c:ares_buf_fetch:
  500|  8.27M|{
  501|  8.27M|  if (len != NULL) {
  ------------------
  |  Branch (501:7): [True: 8.27M, False: 0]
  ------------------
  502|  8.27M|    *len = 0;
  503|  8.27M|  }
  504|       |
  505|  8.27M|  if (buf == NULL || len == NULL || buf->data == NULL) {
  ------------------
  |  Branch (505:7): [True: 0, False: 8.27M]
  |  Branch (505:22): [True: 0, False: 8.27M]
  |  Branch (505:37): [True: 22.6k, False: 8.25M]
  ------------------
  506|  22.6k|    return NULL;
  507|  22.6k|  }
  508|       |
  509|  8.25M|  *len = buf->data_len - buf->offset;
  510|  8.25M|  if (*len == 0) {
  ------------------
  |  Branch (510:7): [True: 1.91k, False: 8.25M]
  ------------------
  511|  1.91k|    return NULL;
  512|  1.91k|  }
  513|       |
  514|  8.25M|  return buf->data + buf->offset;
  515|  8.25M|}
ares_buf.c:ares_buf_parse_dns_binstr_int:
 1221|  6.57k|{
 1222|  6.57k|  unsigned char len;
 1223|  6.57k|  ares_status_t status = ARES_EBADRESP;
 1224|  6.57k|  ares_buf_t   *binbuf = NULL;
 1225|       |
 1226|  6.57k|  if (buf == NULL) {
  ------------------
  |  Branch (1226:7): [True: 0, False: 6.57k]
  ------------------
 1227|      0|    return ARES_EFORMERR;
 1228|      0|  }
 1229|       |
 1230|  6.57k|  if (remaining_len == 0) {
  ------------------
  |  Branch (1230:7): [True: 3, False: 6.57k]
  ------------------
 1231|      3|    return ARES_EBADRESP;
 1232|      3|  }
 1233|       |
 1234|  6.57k|  binbuf = ares_buf_create();
 1235|  6.57k|  if (binbuf == NULL) {
  ------------------
  |  Branch (1235:7): [True: 0, False: 6.57k]
  ------------------
 1236|      0|    return ARES_ENOMEM;
 1237|      0|  }
 1238|       |
 1239|  6.57k|  status = ares_buf_fetch_bytes(buf, &len, 1);
 1240|  6.57k|  if (status != ARES_SUCCESS) {
  ------------------
  |  Branch (1240:7): [True: 0, False: 6.57k]
  ------------------
 1241|      0|    goto done; /* LCOV_EXCL_LINE: DefensiveCoding */
 1242|      0|  }
 1243|       |
 1244|  6.57k|  remaining_len--;
 1245|       |
 1246|  6.57k|  if (len > remaining_len) {
  ------------------
  |  Branch (1246:7): [True: 6, False: 6.56k]
  ------------------
 1247|      6|    status = ARES_EBADRESP;
 1248|      6|    goto done;
 1249|      6|  }
 1250|       |
 1251|  6.56k|  if (len) {
  ------------------
  |  Branch (1251:7): [True: 2.59k, False: 3.96k]
  ------------------
 1252|       |    /* When used by the _str() parser, it really needs to be validated to
 1253|       |     * be a valid printable ascii string.  Do that here */
 1254|  2.59k|    if (validate_printable && ares_buf_len(buf) >= len) {
  ------------------
  |  Branch (1254:9): [True: 2.59k, False: 0]
  |  Branch (1254:31): [True: 2.59k, False: 0]
  ------------------
 1255|  2.59k|      size_t      mylen;
 1256|  2.59k|      const char *data = (const char *)ares_buf_peek(buf, &mylen);
 1257|  2.59k|      if (!ares_str_isprint(data, len)) {
  ------------------
  |  Branch (1257:11): [True: 26, False: 2.56k]
  ------------------
 1258|     26|        status = ARES_EBADSTR;
 1259|     26|        goto done;
 1260|     26|      }
 1261|  2.59k|    }
 1262|       |
 1263|  2.56k|    if (bin != NULL) {
  ------------------
  |  Branch (1263:9): [True: 2.56k, False: 0]
  ------------------
 1264|  2.56k|      status = ares_buf_fetch_bytes_into_buf(buf, binbuf, len);
 1265|  2.56k|    } else {
 1266|      0|      status = ares_buf_consume(buf, len);
 1267|      0|    }
 1268|  2.56k|  }
 1269|       |
 1270|  6.57k|done:
 1271|  6.57k|  if (status == ARES_SUCCESS && bin != NULL) {
  ------------------
  |  Branch (1271:7): [True: 6.53k, False: 32]
  |  Branch (1271:33): [True: 6.53k, False: 0]
  ------------------
 1272|  6.53k|    size_t mylen = 0;
 1273|       |    /* NOTE: we use ares_buf_finish_str() here as we guarantee NULL
 1274|       |     *       Termination even though we are technically returning binary data.
 1275|       |     */
 1276|  6.53k|    *bin     = (unsigned char *)ares_buf_finish_str(binbuf, &mylen);
 1277|  6.53k|    *bin_len = mylen;
 1278|  6.53k|  } else {
 1279|     32|    ares_buf_destroy(binbuf);
 1280|     32|  }
 1281|       |
 1282|  6.57k|  return status;
 1283|  6.56k|}

ares_strlen:
   53|  1.17M|{
   54|  1.17M|  if (str == NULL) {
  ------------------
  |  Branch (54:7): [True: 0, False: 1.17M]
  ------------------
   55|      0|    return 0;
   56|      0|  }
   57|       |
   58|  1.17M|  return strlen(str);
   59|  1.17M|}
ares_strdup:
   62|  68.8k|{
   63|  68.8k|  size_t len;
   64|  68.8k|  char  *out;
   65|       |
   66|  68.8k|  if (s1 == NULL) {
  ------------------
  |  Branch (66:7): [True: 0, False: 68.8k]
  ------------------
   67|      0|    return NULL;
   68|      0|  }
   69|       |
   70|  68.8k|  len = ares_strlen(s1);
   71|       |
   72|       |  /* Don't see how this is possible */
   73|  68.8k|  if (len == SIZE_MAX) {
  ------------------
  |  Branch (73:7): [True: 0, False: 68.8k]
  ------------------
   74|      0|    return NULL; /* LCOV_EXCL_LINE: DefensiveCoding */
   75|      0|  }
   76|       |
   77|  68.8k|  out = ares_malloc(len + 1);
   78|  68.8k|  if (out == NULL) {
  ------------------
  |  Branch (78:7): [True: 0, False: 68.8k]
  ------------------
   79|      0|    return NULL;
   80|      0|  }
   81|       |
   82|  68.8k|  if (len) {
  ------------------
  |  Branch (82:7): [True: 7.72k, False: 61.1k]
  ------------------
   83|  7.72k|    memcpy(out, s1, len);
   84|  7.72k|  }
   85|       |
   86|  68.8k|  out[len] = 0;
   87|  68.8k|  return out;
   88|  68.8k|}
ares_strcpy:
   91|  32.9k|{
   92|  32.9k|  size_t len = 0;
   93|       |
   94|  32.9k|  if (dest == NULL || dest_size == 0) {
  ------------------
  |  Branch (94:7): [True: 0, False: 32.9k]
  |  Branch (94:23): [True: 0, False: 32.9k]
  ------------------
   95|      0|    return 0; /* LCOV_EXCL_LINE: DefensiveCoding */
   96|      0|  }
   97|       |
   98|  32.9k|  len = ares_strlen(src);
   99|       |
  100|  32.9k|  if (len >= dest_size) {
  ------------------
  |  Branch (100:7): [True: 250, False: 32.6k]
  ------------------
  101|    250|    len = dest_size - 1;
  102|    250|  }
  103|       |
  104|  32.9k|  if (len) {
  ------------------
  |  Branch (104:7): [True: 10.2k, False: 22.6k]
  ------------------
  105|  10.2k|    memcpy(dest, src, len);
  106|  10.2k|  }
  107|       |
  108|  32.9k|  dest[len] = 0;
  109|  32.9k|  return len;
  110|  32.9k|}
ares_str_isprint:
  307|  3.42k|{
  308|  3.42k|  size_t i;
  309|       |
  310|  3.42k|  if (str == NULL && len != 0) {
  ------------------
  |  Branch (310:7): [True: 0, False: 3.42k]
  |  Branch (310:22): [True: 0, False: 0]
  ------------------
  311|      0|    return ARES_FALSE;
  312|      0|  }
  313|       |
  314|  32.5k|  for (i = 0; i < len; i++) {
  ------------------
  |  Branch (314:15): [True: 29.1k, False: 3.39k]
  ------------------
  315|  29.1k|    if (!ares_isprint(str[i])) {
  ------------------
  |  |  114|  29.1k|  (((unsigned char)(x)) >= 0x20 && ((unsigned char)(x)) <= 0x7E)
  |  |  ------------------
  |  |  |  Branch (114:4): [True: 29.1k, False: 14]
  |  |  |  Branch (114:36): [True: 29.0k, False: 12]
  |  |  ------------------
  ------------------
  316|     26|      return ARES_FALSE;
  317|     26|    }
  318|  29.1k|  }
  319|  3.39k|  return ARES_TRUE;
  320|  3.42k|}
ares_strcmp:
  323|  6.60k|{
  324|  6.60k|  if (a == NULL && b == NULL) {
  ------------------
  |  Branch (324:7): [True: 0, False: 6.60k]
  |  Branch (324:20): [True: 0, False: 0]
  ------------------
  325|      0|    return 0;
  326|      0|  }
  327|       |
  328|  6.60k|  if (a != NULL && b == NULL) {
  ------------------
  |  Branch (328:7): [True: 6.60k, False: 0]
  |  Branch (328:20): [True: 0, False: 6.60k]
  ------------------
  329|      0|    if (*a == 0) {
  ------------------
  |  Branch (329:9): [True: 0, False: 0]
  ------------------
  330|      0|      return 0;
  331|      0|    }
  332|      0|    return 1;
  333|      0|  }
  334|       |
  335|  6.60k|  if (a == NULL && b != NULL) {
  ------------------
  |  Branch (335:7): [True: 0, False: 6.60k]
  |  Branch (335:20): [True: 0, False: 0]
  ------------------
  336|      0|    if (*b == 0) {
  ------------------
  |  Branch (336:9): [True: 0, False: 0]
  ------------------
  337|      0|      return 0;
  338|      0|    }
  339|      0|    return -1;
  340|      0|  }
  341|       |
  342|  6.60k|  return strcmp(a, b);
  343|  6.60k|}
ares_streq:
  477|  6.60k|{
  478|  6.60k|  return ares_strcmp(a, b) == 0 ? ARES_TRUE : ARES_FALSE;
  ------------------
  |  Branch (478:10): [True: 2.47k, False: 4.12k]
  ------------------
  479|  6.60k|}

ares_is_64bit:
   60|   297k|{
   61|       |#ifdef _MSC_VER
   62|       |#  pragma warning(push)
   63|       |#  pragma warning(disable : 4127)
   64|       |#endif
   65|       |
   66|   297k|  return (sizeof(size_t) == 4) ? ARES_FALSE : ARES_TRUE;
  ------------------
  |  Branch (66:10): [Folded, False: 297k]
  ------------------
   67|       |
   68|       |#ifdef _MSC_VER
   69|       |#  pragma warning(pop)
   70|       |#endif
   71|   297k|}
ares_round_up_pow2:
   74|   297k|{
   75|   297k|  if (ares_is_64bit()) {
  ------------------
  |  Branch (75:7): [True: 297k, False: 0]
  ------------------
   76|   297k|    return (size_t)ares_round_up_pow2_u64((ares_uint64_t)n);
   77|   297k|  }
   78|       |
   79|      0|  return (size_t)ares_round_up_pow2_u32((unsigned int)n);
   80|   297k|}
ares_pow:
  104|   129k|{
  105|   129k|  size_t res = 1;
  106|       |
  107|   371k|  while (y > 0) {
  ------------------
  |  Branch (107:10): [True: 242k, False: 129k]
  ------------------
  108|       |    /* If y is odd, multiply x with result */
  109|   242k|    if (y & 1) {
  ------------------
  |  Branch (109:9): [True: 171k, False: 70.9k]
  ------------------
  110|   171k|      res = res * x;
  111|   171k|    }
  112|       |
  113|       |    /* y must be even now */
  114|   242k|    y = y >> 1; /* y /= 2; */
  115|   242k|    x = x * x;  /* x^2 */
  116|   242k|  }
  117|       |
  118|   129k|  return res;
  119|   129k|}
ares_count_digits:
  122|   129k|{
  123|   129k|  size_t digits;
  124|       |
  125|   469k|  for (digits = 0; n > 0; digits++) {
  ------------------
  |  Branch (125:20): [True: 339k, False: 129k]
  ------------------
  126|   339k|    n /= 10;
  127|   339k|  }
  128|   129k|  if (digits == 0) {
  ------------------
  |  Branch (128:7): [True: 70.4k, False: 59.2k]
  ------------------
  129|  70.4k|    digits = 1;
  130|  70.4k|  }
  131|       |
  132|   129k|  return digits;
  133|   129k|}
ares_count_hexdigits:
  136|  1.82k|{
  137|  1.82k|  size_t digits;
  138|       |
  139|  4.40k|  for (digits = 0; n > 0; digits++) {
  ------------------
  |  Branch (139:20): [True: 2.58k, False: 1.82k]
  ------------------
  140|  2.58k|    n /= 16;
  141|  2.58k|  }
  142|  1.82k|  if (digits == 0) {
  ------------------
  |  Branch (142:7): [True: 395, False: 1.42k]
  ------------------
  143|    395|    digits = 1;
  144|    395|  }
  145|       |
  146|  1.82k|  return digits;
  147|  1.82k|}
ares_math.c:ares_round_up_pow2_u64:
   46|   297k|{
   47|       |  /* NOTE: if already a power of 2, will return itself, not the next */
   48|   297k|  n--;
   49|   297k|  n |= n >> 1;
   50|   297k|  n |= n >> 2;
   51|   297k|  n |= n >> 4;
   52|   297k|  n |= n >> 8;
   53|   297k|  n |= n >> 16;
   54|   297k|  n |= n >> 32;
   55|   297k|  n++;
   56|   297k|  return n;
   57|   297k|}

LLVMFuzzerTestOneInput:
  130|  3.40k|{
  131|  3.40k|  ares_dns_record_t *dnsrec    = NULL;
  132|  3.40k|  char              *printdata = NULL;
  133|  3.40k|  ares_buf_t        *printmsg  = NULL;
  134|  3.40k|  size_t             i;
  135|  3.40k|  unsigned char     *datadup     = NULL;
  136|  3.40k|  size_t             datadup_len = 0;
  137|       |
  138|       |  /* There is never a reason to have a size > 65535, it is immediately
  139|       |   * rejected by the parser */
  140|  3.40k|  if (size > 65535) {
  ------------------
  |  Branch (140:7): [True: 6, False: 3.39k]
  ------------------
  141|      6|    return -1;
  142|      6|  }
  143|       |
  144|  3.39k|  if (ares_dns_parse(data, size, 0, &dnsrec) != ARES_SUCCESS) {
  ------------------
  |  Branch (144:7): [True: 1.57k, False: 1.82k]
  ------------------
  145|  1.57k|    goto done;
  146|  1.57k|  }
  147|       |
  148|       |  /* Lets test the message fetchers */
  149|  1.82k|  printmsg = ares_buf_create();
  150|  1.82k|  if (printmsg == NULL) {
  ------------------
  |  Branch (150:7): [True: 0, False: 1.82k]
  ------------------
  151|      0|    goto done;
  152|      0|  }
  153|       |
  154|  1.82k|  ares_buf_append_str(printmsg, ";; ->>HEADER<<- opcode: ");
  155|  1.82k|  ares_buf_append_str(
  156|  1.82k|    printmsg, ares_dns_opcode_tostr(ares_dns_record_get_opcode(dnsrec)));
  157|  1.82k|  ares_buf_append_str(printmsg, ", status: ");
  158|  1.82k|  ares_buf_append_str(printmsg,
  159|  1.82k|                      ares_dns_rcode_tostr(ares_dns_record_get_rcode(dnsrec)));
  160|  1.82k|  ares_buf_append_str(printmsg, ", id: ");
  161|  1.82k|  ares_buf_append_num_dec(printmsg, (size_t)ares_dns_record_get_id(dnsrec), 0);
  162|  1.82k|  ares_buf_append_str(printmsg, "\n;; flags: ");
  163|  1.82k|  ares_buf_append_num_hex(printmsg, (size_t)ares_dns_record_get_flags(dnsrec),
  164|  1.82k|                          0);
  165|  1.82k|  ares_buf_append_str(printmsg, "; QUERY: ");
  166|  1.82k|  ares_buf_append_num_dec(printmsg, ares_dns_record_query_cnt(dnsrec), 0);
  167|  1.82k|  ares_buf_append_str(printmsg, ", ANSWER: ");
  168|  1.82k|  ares_buf_append_num_dec(
  169|  1.82k|    printmsg, ares_dns_record_rr_cnt(dnsrec, ARES_SECTION_ANSWER), 0);
  170|  1.82k|  ares_buf_append_str(printmsg, ", AUTHORITY: ");
  171|  1.82k|  ares_buf_append_num_dec(
  172|  1.82k|    printmsg, ares_dns_record_rr_cnt(dnsrec, ARES_SECTION_AUTHORITY), 0);
  173|  1.82k|  ares_buf_append_str(printmsg, ", ADDITIONAL: ");
  174|  1.82k|  ares_buf_append_num_dec(
  175|  1.82k|    printmsg, ares_dns_record_rr_cnt(dnsrec, ARES_SECTION_ADDITIONAL), 0);
  176|  1.82k|  ares_buf_append_str(printmsg, "\n\n");
  177|  1.82k|  ares_buf_append_str(printmsg, ";; QUESTION SECTION:\n");
  178|  3.64k|  for (i = 0; i < ares_dns_record_query_cnt(dnsrec); i++) {
  ------------------
  |  Branch (178:15): [True: 1.82k, False: 1.82k]
  ------------------
  179|  1.82k|    const char         *name;
  180|  1.82k|    ares_dns_rec_type_t qtype;
  181|  1.82k|    ares_dns_class_t    qclass;
  182|       |
  183|  1.82k|    if (ares_dns_record_query_get(dnsrec, i, &name, &qtype, &qclass) !=
  ------------------
  |  Branch (183:9): [True: 0, False: 1.82k]
  ------------------
  184|  1.82k|        ARES_SUCCESS) {
  185|      0|      goto done;
  186|      0|    }
  187|       |
  188|  1.82k|    ares_buf_append_str(printmsg, ";");
  189|  1.82k|    ares_buf_append_str(printmsg, name);
  190|  1.82k|    ares_buf_append_str(printmsg, ".\t\t\t");
  191|  1.82k|    ares_buf_append_str(printmsg, ares_dns_class_tostr(qclass));
  192|  1.82k|    ares_buf_append_str(printmsg, "\t");
  193|  1.82k|    ares_buf_append_str(printmsg, ares_dns_rec_type_tostr(qtype));
  194|  1.82k|    ares_buf_append_str(printmsg, "\n");
  195|  1.82k|  }
  196|  1.82k|  ares_buf_append_str(printmsg, "\n");
  197|  7.28k|  for (i = ARES_SECTION_ANSWER; i < ARES_SECTION_ADDITIONAL + 1; i++) {
  ------------------
  |  Branch (197:33): [True: 5.46k, False: 1.82k]
  ------------------
  198|  5.46k|    size_t j;
  199|       |
  200|  5.46k|    ares_buf_append_str(printmsg, ";; ");
  201|  5.46k|    ares_buf_append_str(printmsg,
  202|  5.46k|                        ares_dns_section_tostr((ares_dns_section_t)i));
  203|  5.46k|    ares_buf_append_str(printmsg, " SECTION:\n");
  204|  61.4k|    for (j = 0; j < ares_dns_record_rr_cnt(dnsrec, (ares_dns_section_t)i);
  ------------------
  |  Branch (204:17): [True: 55.9k, False: 5.46k]
  ------------------
  205|  55.9k|         j++) {
  206|  55.9k|      size_t                   keys_cnt = 0;
  207|  55.9k|      const ares_dns_rr_key_t *keys     = NULL;
  208|  55.9k|      ares_dns_rr_t           *rr       = NULL;
  209|  55.9k|      size_t                   k;
  210|       |
  211|  55.9k|      rr = ares_dns_record_rr_get(dnsrec, (ares_dns_section_t)i, j);
  212|  55.9k|      ares_buf_append_str(printmsg, ares_dns_rr_get_name(rr));
  213|  55.9k|      ares_buf_append_str(printmsg, ".\t\t\t");
  214|  55.9k|      ares_buf_append_str(printmsg,
  215|  55.9k|                          ares_dns_class_tostr(ares_dns_rr_get_class(rr)));
  216|  55.9k|      ares_buf_append_str(printmsg, "\t");
  217|  55.9k|      ares_buf_append_str(printmsg,
  218|  55.9k|                          ares_dns_rec_type_tostr(ares_dns_rr_get_type(rr)));
  219|  55.9k|      ares_buf_append_str(printmsg, "\t");
  220|  55.9k|      ares_buf_append_num_dec(printmsg, ares_dns_rr_get_ttl(rr), 0);
  221|  55.9k|      ares_buf_append_str(printmsg, "\t");
  222|       |
  223|  55.9k|      keys = ares_dns_rr_get_keys(ares_dns_rr_get_type(rr), &keys_cnt);
  224|   181k|      for (k = 0; k < keys_cnt; k++) {
  ------------------
  |  Branch (224:19): [True: 125k, False: 55.9k]
  ------------------
  225|   125k|        char buf[256] = "";
  226|       |
  227|   125k|        ares_buf_append_str(printmsg, ares_dns_rr_key_tostr(keys[k]));
  228|   125k|        ares_buf_append_str(printmsg, "=");
  229|   125k|        switch (ares_dns_rr_key_datatype(keys[k])) {
  ------------------
  |  Branch (229:17): [True: 125k, False: 0]
  ------------------
  230|    450|          case ARES_DATATYPE_INADDR:
  ------------------
  |  Branch (230:11): [True: 450, False: 125k]
  ------------------
  231|    450|            ares_inet_ntop(AF_INET, ares_dns_rr_get_addr(rr, keys[k]), buf,
  232|    450|                           sizeof(buf));
  233|    450|            ares_buf_append_str(printmsg, buf);
  234|    450|            break;
  235|  6.07k|          case ARES_DATATYPE_INADDR6:
  ------------------
  |  Branch (235:11): [True: 6.07k, False: 119k]
  ------------------
  236|  6.07k|            ares_inet_ntop(AF_INET6, ares_dns_rr_get_addr6(rr, keys[k]), buf,
  237|  6.07k|                           sizeof(buf));
  238|  6.07k|            ares_buf_append_str(printmsg, buf);
  239|  6.07k|            break;
  240|  6.89k|          case ARES_DATATYPE_U8:
  ------------------
  |  Branch (240:11): [True: 6.89k, False: 118k]
  ------------------
  241|  6.89k|            ares_buf_append_num_dec(printmsg, ares_dns_rr_get_u8(rr, keys[k]),
  242|  6.89k|                                    0);
  243|  6.89k|            break;
  244|  48.6k|          case ARES_DATATYPE_U16:
  ------------------
  |  Branch (244:11): [True: 48.6k, False: 77.0k]
  ------------------
  245|  48.6k|            ares_buf_append_num_dec(printmsg, ares_dns_rr_get_u16(rr, keys[k]),
  246|  48.6k|                                    0);
  247|  48.6k|            break;
  248|  7.13k|          case ARES_DATATYPE_U32:
  ------------------
  |  Branch (248:11): [True: 7.13k, False: 118k]
  ------------------
  249|  7.13k|            ares_buf_append_num_dec(printmsg, ares_dns_rr_get_u32(rr, keys[k]),
  250|  7.13k|                                    0);
  251|  7.13k|            break;
  252|  12.0k|          case ARES_DATATYPE_NAME:
  ------------------
  |  Branch (252:11): [True: 12.0k, False: 113k]
  ------------------
  253|  16.3k|          case ARES_DATATYPE_STR:
  ------------------
  |  Branch (253:11): [True: 4.30k, False: 121k]
  ------------------
  254|  16.3k|            ares_buf_append_byte(printmsg, '"');
  255|  16.3k|            ares_buf_append_str(printmsg, ares_dns_rr_get_str(rr, keys[k]));
  256|  16.3k|            ares_buf_append_byte(printmsg, '"');
  257|  16.3k|            break;
  258|  34.1k|          case ARES_DATATYPE_BIN:
  ------------------
  |  Branch (258:11): [True: 34.1k, False: 91.5k]
  ------------------
  259|       |            /* TODO */
  260|  34.1k|            break;
  261|    542|          case ARES_DATATYPE_BINP:
  ------------------
  |  Branch (261:11): [True: 542, False: 125k]
  ------------------
  262|    542|            {
  263|    542|              size_t templen;
  264|    542|              ares_buf_append_byte(printmsg, '"');
  265|    542|              ares_buf_append_str(printmsg, (const char *)ares_dns_rr_get_bin(
  266|    542|                                              rr, keys[k], &templen));
  267|    542|              ares_buf_append_byte(printmsg, '"');
  268|    542|            }
  269|    542|            break;
  270|  1.17k|          case ARES_DATATYPE_ABINP:
  ------------------
  |  Branch (270:11): [True: 1.17k, False: 124k]
  ------------------
  271|  1.17k|            {
  272|  1.17k|              size_t a;
  273|   138k|              for (a = 0; a < ares_dns_rr_get_abin_cnt(rr, keys[k]); a++) {
  ------------------
  |  Branch (273:27): [True: 137k, False: 1.17k]
  ------------------
  274|   137k|                size_t templen;
  275|       |
  276|   137k|                if (a != 0) {
  ------------------
  |  Branch (276:21): [True: 135k, False: 1.17k]
  ------------------
  277|   135k|                  ares_buf_append_byte(printmsg, ' ');
  278|   135k|                }
  279|   137k|                ares_buf_append_byte(printmsg, '"');
  280|   137k|                ares_buf_append_str(
  281|   137k|                  printmsg,
  282|   137k|                  (const char *)ares_dns_rr_get_abin(rr, keys[k], a, &templen));
  283|   137k|                ares_buf_append_byte(printmsg, '"');
  284|   137k|              }
  285|  1.17k|            }
  286|  1.17k|            break;
  287|  4.31k|          case ARES_DATATYPE_OPT:
  ------------------
  |  Branch (287:11): [True: 4.31k, False: 121k]
  ------------------
  288|       |            /* TODO */
  289|  4.31k|            break;
  290|   125k|        }
  291|   125k|        ares_buf_append_str(printmsg, " ");
  292|   125k|      }
  293|  55.9k|      ares_buf_append_str(printmsg, "\n");
  294|  55.9k|    }
  295|  5.46k|  }
  296|  1.82k|  ares_buf_append_str(printmsg, ";; SIZE: ");
  297|  1.82k|  ares_buf_append_num_dec(printmsg, size, 0);
  298|  1.82k|  ares_buf_append_str(printmsg, "\n\n");
  299|       |
  300|  1.82k|  printdata = ares_buf_finish_str(printmsg, NULL);
  301|  1.82k|  printmsg  = NULL;
  302|       |
  303|       |  /* Write it back out as a dns message to test writer */
  304|  1.82k|  if (ares_dns_write(dnsrec, &datadup, &datadup_len) != ARES_SUCCESS) {
  ------------------
  |  Branch (304:7): [True: 773, False: 1.04k]
  ------------------
  305|    773|    goto done;
  306|    773|  }
  307|       |
  308|  3.39k|done:
  309|  3.39k|  ares_dns_record_destroy(dnsrec);
  310|  3.39k|  ares_buf_destroy(printmsg);
  311|  3.39k|  ares_free(printdata);
  312|  3.39k|  ares_free(datadup);
  313|  3.39k|  return 0;
  314|  1.82k|}

