is_name_synthetic:
   26|    658|{
   27|    658|  char *p;
   28|    658|  struct cond_domain *c = NULL;
   29|    658|  int prot = (flags & F_IPV6) ? AF_INET6 : AF_INET;
  ------------------
  |  |  523|    658|#define F_IPV6      (1u<<8)
  ------------------
  |  Branch (29:14): [True: 0, False: 658]
  ------------------
   30|    658|  union all_addr addr;
   31|       |  
   32|    658|  for (c = daemon->synth_domains; c; c = c->next)
  ------------------
  |  |  169|    658|#define daemon dnsmasq_daemon
  ------------------
  |  Branch (32:35): [True: 0, False: 658]
  ------------------
   33|      0|    {
   34|      0|      int found = 0;
   35|      0|      char *tail, *pref;
   36|       |      
   37|      0|      for (tail = name, pref = c->prefix; *tail != 0 && pref && *pref != 0; tail++, pref++)
  ------------------
  |  Branch (37:43): [True: 0, False: 0]
  |  Branch (37:57): [True: 0, False: 0]
  |  Branch (37:65): [True: 0, False: 0]
  ------------------
   38|      0|	{
   39|      0|	  unsigned int c1 = (unsigned char) *pref;
   40|      0|	  unsigned int c2 = (unsigned char) *tail;
   41|       |	  
   42|      0|	  if (c1 >= 'A' && c1 <= 'Z')
  ------------------
  |  Branch (42:8): [True: 0, False: 0]
  |  Branch (42:21): [True: 0, False: 0]
  ------------------
   43|      0|	    c1 += 'a' - 'A';
   44|      0|	  if (c2 >= 'A' && c2 <= 'Z')
  ------------------
  |  Branch (44:8): [True: 0, False: 0]
  |  Branch (44:21): [True: 0, False: 0]
  ------------------
   45|      0|	    c2 += 'a' - 'A';
   46|       |	  
   47|      0|	  if (c1 != c2)
  ------------------
  |  Branch (47:8): [True: 0, False: 0]
  ------------------
   48|      0|	    break;
   49|      0|	}
   50|       |      
   51|      0|      if (pref && *pref != 0)
  ------------------
  |  Branch (51:11): [True: 0, False: 0]
  |  Branch (51:19): [True: 0, False: 0]
  ------------------
   52|      0|	continue; /* prefix match fail */
   53|       |
   54|      0|      if (c->indexed)
  ------------------
  |  Branch (54:11): [True: 0, False: 0]
  ------------------
   55|      0|	{
   56|      0|	  for (p = tail; *p; p++)
  ------------------
  |  Branch (56:19): [True: 0, False: 0]
  ------------------
   57|      0|	    {
   58|      0|	      char c = *p;
   59|       |	      
   60|      0|	      if (c < '0' || c > '9')
  ------------------
  |  Branch (60:12): [True: 0, False: 0]
  |  Branch (60:23): [True: 0, False: 0]
  ------------------
   61|      0|		break;
   62|      0|	    }
   63|       |	  
   64|      0|	  if (*p != '.')
  ------------------
  |  Branch (64:8): [True: 0, False: 0]
  ------------------
   65|      0|	    continue;
   66|       |	  
   67|      0|	  *p = 0;
   68|       |	  
   69|      0|	  if (hostname_isequal(c->domain, p+1))
  ------------------
  |  Branch (69:8): [True: 0, False: 0]
  ------------------
   70|      0|	    {
   71|      0|	      if (prot == AF_INET)
  ------------------
  |  Branch (71:12): [True: 0, False: 0]
  ------------------
   72|      0|		{
   73|      0|		  unsigned int index = atoi(tail);
   74|       |
   75|      0|		   if (!c->is6 &&
  ------------------
  |  Branch (75:10): [True: 0, False: 0]
  ------------------
   76|      0|		      index <= ntohl(c->end.s_addr) - ntohl(c->start.s_addr))
  ------------------
  |  Branch (76:9): [True: 0, False: 0]
  ------------------
   77|      0|		    {
   78|      0|		      addr.addr4.s_addr = htonl(ntohl(c->start.s_addr) + index);
   79|      0|		      found = 1;
   80|      0|		    }
   81|      0|		} 
   82|      0|	      else
   83|      0|		{
   84|      0|		  u64 index = atoll(tail);
   85|       |		  
   86|      0|		  if (c->is6 &&
  ------------------
  |  Branch (86:9): [True: 0, False: 0]
  ------------------
   87|      0|		      index <= addr6part(&c->end6) - addr6part(&c->start6))
  ------------------
  |  Branch (87:9): [True: 0, False: 0]
  ------------------
   88|      0|		    {
   89|      0|		      u64 start = addr6part(&c->start6);
   90|      0|		      addr.addr6 = c->start6;
   91|      0|		      setaddr6part(&addr.addr6, start + index);
   92|      0|		      found = 1;
   93|      0|		    }
   94|      0|		}
   95|      0|	    }
   96|      0|	}
   97|      0|      else
   98|      0|	{
   99|       |	  /* NB, must not alter name if we return zero */
  100|      0|	  for (p = tail; *p; p++)
  ------------------
  |  Branch (100:19): [True: 0, False: 0]
  ------------------
  101|      0|	    {
  102|      0|	      char c = *p;
  103|       |	      
  104|      0|	      if ((c >='0' && c <= '9') || c == '-')
  ------------------
  |  Branch (104:13): [True: 0, False: 0]
  |  Branch (104:24): [True: 0, False: 0]
  |  Branch (104:37): [True: 0, False: 0]
  ------------------
  105|      0|		continue;
  106|       |	      
  107|      0|	      if (prot == AF_INET6 && ((c >='A' && c <= 'F') || (c >='a' && c <= 'f'))) 
  ------------------
  |  Branch (107:12): [True: 0, False: 0]
  |  Branch (107:34): [True: 0, False: 0]
  |  Branch (107:45): [True: 0, False: 0]
  |  Branch (107:59): [True: 0, False: 0]
  |  Branch (107:70): [True: 0, False: 0]
  ------------------
  108|      0|		continue;
  109|       |	      
  110|      0|	      break;
  111|      0|	    }
  112|       |	  
  113|      0|	  if (*p != '.')
  ------------------
  |  Branch (113:8): [True: 0, False: 0]
  ------------------
  114|      0|	    continue;
  115|       |	  
  116|      0|	  *p = 0;	
  117|       |	  
  118|       |	  /* swap . or : for - */
  119|      0|	  for (p = tail; *p; p++)
  ------------------
  |  Branch (119:19): [True: 0, False: 0]
  ------------------
  120|      0|	    if (*p == '-')
  ------------------
  |  Branch (120:10): [True: 0, False: 0]
  ------------------
  121|      0|	      {
  122|      0|		if (prot == AF_INET)
  ------------------
  |  Branch (122:7): [True: 0, False: 0]
  ------------------
  123|      0|		  *p = '.';
  124|      0|		else
  125|      0|		  *p = ':';
  126|      0|	      }
  127|       |	  
  128|      0|	  if (hostname_isequal(c->domain, p+1) && inet_pton(prot, tail, &addr))
  ------------------
  |  Branch (128:8): [True: 0, False: 0]
  |  Branch (128:44): [True: 0, False: 0]
  ------------------
  129|      0|	    found = (prot == AF_INET) ? match_domain(addr.addr4, c) : match_domain6(&addr.addr6, c);
  ------------------
  |  Branch (129:14): [True: 0, False: 0]
  ------------------
  130|      0|	}
  131|       |      
  132|       |      /* restore name */
  133|      0|      for (p = tail; *p; p++)
  ------------------
  |  Branch (133:22): [True: 0, False: 0]
  ------------------
  134|      0|	if (*p == '.' || *p == ':')
  ------------------
  |  Branch (134:6): [True: 0, False: 0]
  |  Branch (134:19): [True: 0, False: 0]
  ------------------
  135|      0|	  *p = '-';
  136|       |      
  137|      0|      *p = '.';
  138|       |      
  139|       |      
  140|      0|      if (found)
  ------------------
  |  Branch (140:11): [True: 0, False: 0]
  ------------------
  141|      0|	{
  142|      0|	  if (addrp)
  ------------------
  |  Branch (142:8): [True: 0, False: 0]
  ------------------
  143|      0|	    *addrp = addr;
  144|       |	  
  145|      0|	  return 1;
  146|      0|	}
  147|      0|    }
  148|       |  
  149|    658|  return 0;
  150|    658|}

legal_hostname:
  215|    658|{
  216|    658|  char c;
  217|    658|  int first;
  218|       |
  219|    658|  if (!check_name(name))
  ------------------
  |  Branch (219:7): [True: 317, False: 341]
  ------------------
  220|    317|    return 0;
  221|       |
  222|  1.72k|  for (first = 1; (c = *name); name++, first = 0)
  ------------------
  |  Branch (222:19): [True: 1.54k, False: 173]
  ------------------
  223|       |    /* check for legal char a-z A-Z 0-9 - _ . */
  224|  1.54k|    {
  225|  1.54k|      if ((c >= 'A' && c <= 'Z') ||
  ------------------
  |  Branch (225:12): [True: 1.01k, False: 528]
  |  Branch (225:24): [True: 402, False: 617]
  ------------------
  226|  1.14k|	  (c >= 'a' && c <= 'z') ||
  ------------------
  |  Branch (226:5): [True: 484, False: 661]
  |  Branch (226:17): [True: 479, False: 5]
  ------------------
  227|    666|	  (c >= '0' && c <= '9'))
  ------------------
  |  Branch (227:5): [True: 464, False: 202]
  |  Branch (227:17): [True: 296, False: 168]
  ------------------
  228|  1.17k|	continue;
  229|       |
  230|    370|      if (!first && (c == '-' || c == '_'))
  ------------------
  |  Branch (230:11): [True: 252, False: 118]
  |  Branch (230:22): [True: 87, False: 165]
  |  Branch (230:34): [True: 115, False: 50]
  ------------------
  231|    202|	continue;
  232|       |      
  233|       |      /* end of hostname part */
  234|    168|      if (c == '.')
  ------------------
  |  Branch (234:11): [True: 9, False: 159]
  ------------------
  235|      9|	return 1;
  236|       |      
  237|    159|      return 0;
  238|    168|    }
  239|       |  
  240|    173|  return 1;
  241|    341|}
canonicalise:
  244|    658|{
  245|    658|  char *ret = NULL;
  246|    658|  int rc;
  247|       |  
  248|    658|  if (nomem)
  ------------------
  |  Branch (248:7): [True: 0, False: 658]
  ------------------
  249|      0|    *nomem = 0;
  250|       |  
  251|    658|  if (!(rc = check_name(in)))
  ------------------
  |  Branch (251:7): [True: 383, False: 275]
  ------------------
  252|    383|    return NULL;
  253|       |  
  254|       |#if defined(HAVE_IDN) || defined(HAVE_LIBIDN2)
  255|       |  if (rc == 2)
  256|       |    {
  257|       |#  ifdef HAVE_LIBIDN2
  258|       |      rc = idn2_to_ascii_lz(in, &ret, IDN2_NONTRANSITIONAL);
  259|       |#  else
  260|       |      rc = idna_to_ascii_lz(in, &ret, 0);
  261|       |#  endif
  262|       |      if (rc != IDNA_SUCCESS)
  263|       |	{
  264|       |	  if (ret)
  265|       |	    free(ret);
  266|       |	  
  267|       |	  if (nomem && (rc == IDNA_MALLOC_ERROR || rc == IDNA_DLOPEN_ERROR))
  268|       |	    {
  269|       |	      my_syslog(LOG_ERR, _("failed to allocate memory"));
  270|       |	      *nomem = 1;
  271|       |	    }
  272|       |	  
  273|       |	  return NULL;
  274|       |	}
  275|       |
  276|       |      /* IDN library doesnt call our malloc wrapper, so log this by steam */
  277|       |      if (ret)
  278|       |	malloc_log(ret, strlen(ret)+1);
  279|       |      
  280|       |      return ret;
  281|       |    }
  282|       |#else
  283|    275|  (void)rc;
  284|    275|#endif
  285|       |  
  286|    275|  if ((ret = whine_malloc(strlen(in)+1)))
  ------------------
  |  | 1508|    275|#define whine_malloc(x) whine_malloc_real(__func__, __LINE__, (x))
  ------------------
  |  Branch (286:7): [True: 275, False: 0]
  ------------------
  287|    275|    strcpy(ret, in);
  288|      0|  else if (nomem)
  ------------------
  |  Branch (288:12): [True: 0, False: 0]
  ------------------
  289|      0|    *nomem = 1;
  290|       |
  291|    275|  return ret;
  292|    658|}
hostname_order:
  405|    210|{
  406|    210|  unsigned int c1, c2;
  407|       |  
  408|  2.87k|  do {
  409|  2.87k|    c1 = (unsigned char) *a++;
  410|  2.87k|    c2 = (unsigned char) *b++;
  411|       |    
  412|  2.87k|    if (c1 >= 'A' && c1 <= 'Z')
  ------------------
  |  Branch (412:9): [True: 1.37k, False: 1.49k]
  |  Branch (412:22): [True: 254, False: 1.12k]
  ------------------
  413|    254|      c1 += 'a' - 'A';
  414|  2.87k|    if (c2 >= 'A' && c2 <= 'Z')
  ------------------
  |  Branch (414:9): [True: 1.40k, False: 1.47k]
  |  Branch (414:22): [True: 272, False: 1.13k]
  ------------------
  415|    272|      c2 += 'a' - 'A';
  416|       |    
  417|  2.87k|    if (c1 < c2)
  ------------------
  |  Branch (417:9): [True: 85, False: 2.79k]
  ------------------
  418|     85|      return -1;
  419|  2.79k|    else if (c1 > c2)
  ------------------
  |  Branch (419:14): [True: 65, False: 2.72k]
  ------------------
  420|     65|      return 1;
  421|       |    
  422|  2.87k|  } while (c1);
  ------------------
  |  Branch (422:12): [True: 2.66k, False: 60]
  ------------------
  423|       |  
  424|     60|  return 0;
  425|    210|}
hostname_isequal:
  428|    658|{
  429|    658|  return strlen(a) == strlen(b) && hostname_order(a, b) == 0;
  ------------------
  |  Branch (429:10): [True: 210, False: 448]
  |  Branch (429:36): [True: 60, False: 150]
  ------------------
  430|    658|}
hostname_issubdomain:
  434|    658|{
  435|    658|  char *ap, *bp;
  436|    658|  unsigned int c1, c2;
  437|       |  
  438|       |  /* move to the end */
  439|  25.9k|  for (ap = a; *ap; ap++); 
  ------------------
  |  Branch (439:16): [True: 25.3k, False: 658]
  ------------------
  440|  38.3k|  for (bp = b; *bp; bp++);
  ------------------
  |  Branch (440:16): [True: 37.6k, False: 658]
  ------------------
  441|       |
  442|       |  /* a shorter than b */
  443|    658|  if ((ap - a) < (bp - b))
  ------------------
  |  Branch (443:7): [True: 182, False: 476]
  ------------------
  444|    182|    return 0;
  445|       |
  446|    476|  do
  447|  2.60k|    {
  448|  2.60k|      c1 = (unsigned char) *(--ap);
  449|  2.60k|      c2 = (unsigned char) *(--bp);
  450|       |  
  451|  2.60k|       if (c1 >= 'A' && c1 <= 'Z')
  ------------------
  |  Branch (451:12): [True: 1.01k, False: 1.58k]
  |  Branch (451:25): [True: 376, False: 640]
  ------------------
  452|    376|	 c1 += 'a' - 'A';
  453|  2.60k|       if (c2 >= 'A' && c2 <= 'Z')
  ------------------
  |  Branch (453:12): [True: 1.02k, False: 1.58k]
  |  Branch (453:25): [True: 401, False: 621]
  ------------------
  454|    401|	 c2 += 'a' - 'A';
  455|       |
  456|  2.60k|       if (c1 != c2)
  ------------------
  |  Branch (456:12): [True: 378, False: 2.22k]
  ------------------
  457|    378|	 return 0;
  458|  2.60k|    } while (bp != b);
  ------------------
  |  Branch (458:14): [True: 2.12k, False: 98]
  ------------------
  459|       |
  460|     98|  if (ap == a)
  ------------------
  |  Branch (460:7): [True: 51, False: 47]
  ------------------
  461|     51|    return 2;
  462|       |
  463|     47|  if (*(--ap) == '.')
  ------------------
  |  Branch (463:7): [True: 4, False: 43]
  ------------------
  464|      4|    return 1;
  465|       |
  466|     43|  return 0;
  467|     47|}
parse_hex:
  611|  1.31k|{
  612|  1.31k|  int done = 0, mask = 0, i = 0;
  613|  1.31k|  char *r;
  614|       |    
  615|  1.31k|  if (mac_type)
  ------------------
  |  Branch (615:7): [True: 658, False: 658]
  ------------------
  616|    658|    *mac_type = 0;
  617|       |  
  618|  9.26k|  while (!done && (maxlen == -1 || i < maxlen))
  ------------------
  |  Branch (618:10): [True: 8.66k, False: 600]
  |  Branch (618:20): [True: 0, False: 8.66k]
  |  Branch (618:36): [True: 8.66k, False: 8]
  ------------------
  619|  8.66k|    {
  620|  23.8k|      for (r = in; *r != 0 && *r != ':' && *r != '-' && *r != ' '; r++)
  ------------------
  |  Branch (620:20): [True: 23.2k, False: 611]
  |  Branch (620:31): [True: 22.5k, False: 657]
  |  Branch (620:44): [True: 21.6k, False: 934]
  |  Branch (620:57): [True: 15.8k, False: 5.76k]
  ------------------
  621|  15.8k|	if (*r != '*' && !isxdigit((unsigned char)*r))
  ------------------
  |  Branch (621:6): [True: 15.1k, False: 720]
  |  Branch (621:19): [True: 695, False: 14.4k]
  ------------------
  622|    695|	  return -1;
  623|       |      
  624|  7.96k|      if (*r == 0)
  ------------------
  |  Branch (624:11): [True: 611, False: 7.35k]
  ------------------
  625|    611|	done = 1;
  626|       |      
  627|  7.96k|      if (r != in )
  ------------------
  |  Branch (627:11): [True: 1.13k, False: 6.83k]
  ------------------
  628|  1.13k|	{
  629|  1.13k|	  if (*r == '-' && i == 0 && mac_type)
  ------------------
  |  Branch (629:8): [True: 266, False: 865]
  |  Branch (629:21): [True: 35, False: 231]
  |  Branch (629:31): [True: 0, False: 35]
  ------------------
  630|      0|	   {
  631|      0|	      *r = 0;
  632|      0|	      *mac_type = strtol(in, NULL, 16);
  633|      0|	      mac_type = NULL;
  634|      0|	   }
  635|  1.13k|	  else
  636|  1.13k|	    {
  637|  1.13k|	      *r = 0;
  638|  1.13k|	      if (strcmp(in, "*") == 0)
  ------------------
  |  Branch (638:12): [True: 462, False: 669]
  ------------------
  639|    462|		{
  640|    462|		  mask = (mask << 1) | 1;
  641|    462|		  i++;
  642|    462|		}
  643|    669|	      else
  644|    669|		{
  645|    669|		  int j, bytes = (1 + (r - in))/2;
  646|  3.34k|		  for (j = 0; j < bytes; j++)
  ------------------
  |  Branch (646:17): [True: 2.73k, False: 608]
  ------------------
  647|  2.73k|		    { 
  648|  2.73k|		      char sav;
  649|  2.73k|		      if (j < bytes - 1)
  ------------------
  |  Branch (649:13): [True: 2.09k, False: 646]
  ------------------
  650|  2.09k|			{
  651|  2.09k|			  sav = in[(j+1)*2];
  652|  2.09k|			  in[(j+1)*2] = 0;
  653|  2.09k|			}
  654|       |		      /* checks above allow mix of hexdigit and *, which
  655|       |			 is illegal. */
  656|  2.73k|		      if (strchr(&in[j*2], '*'))
  ------------------
  |  Branch (656:13): [True: 13, False: 2.72k]
  ------------------
  657|     13|			return -1;
  658|  2.72k|		      out[i] = strtol(&in[j*2], NULL, 16);
  659|  2.72k|		      mask = mask << 1;
  660|  2.72k|		      if (++i == maxlen)
  ------------------
  |  Branch (660:13): [True: 48, False: 2.67k]
  ------------------
  661|     48|			break; 
  662|  2.67k|		      if (j < bytes - 1)
  ------------------
  |  Branch (662:13): [True: 2.06k, False: 608]
  ------------------
  663|  2.06k|			in[(j+1)*2] = sav;
  664|  2.67k|		    }
  665|    669|		}
  666|  1.13k|	    }
  667|  1.13k|	}
  668|  7.95k|      in = r+1;
  669|  7.95k|    }
  670|       |  
  671|    608|  if (wildcard_mask)
  ------------------
  |  Branch (671:7): [True: 0, False: 608]
  ------------------
  672|      0|    *wildcard_mask = mask;
  673|       |
  674|    608|  return i;
  675|  1.31k|}
wildcard_match:
  887|    658|{
  888|  3.07k|  while (*wildcard && *match)
  ------------------
  |  Branch (888:10): [True: 2.99k, False: 86]
  |  Branch (888:23): [True: 2.88k, False: 107]
  ------------------
  889|  2.88k|    {
  890|  2.88k|      if (*wildcard == '*')
  ------------------
  |  Branch (890:11): [True: 46, False: 2.83k]
  ------------------
  891|     46|        return 1;
  892|       |
  893|  2.83k|      if (*wildcard != *match)
  ------------------
  |  Branch (893:11): [True: 419, False: 2.41k]
  ------------------
  894|    419|        return 0; 
  895|       |
  896|  2.41k|      ++wildcard;
  897|  2.41k|      ++match;
  898|  2.41k|    }
  899|       |
  900|    193|  return *wildcard == *match;
  901|    658|}
wildcard_matchn:
  905|    658|{
  906|  3.07k|  while (*wildcard && *match && num)
  ------------------
  |  Branch (906:10): [True: 2.99k, False: 86]
  |  Branch (906:23): [True: 2.88k, False: 107]
  |  Branch (906:33): [True: 2.88k, False: 0]
  ------------------
  907|  2.88k|    {
  908|  2.88k|      if (*wildcard == '*')
  ------------------
  |  Branch (908:11): [True: 46, False: 2.83k]
  ------------------
  909|     46|        return 1;
  910|       |
  911|  2.83k|      if (*wildcard != *match)
  ------------------
  |  Branch (911:11): [True: 419, False: 2.41k]
  ------------------
  912|    419|        return 0; 
  913|       |
  914|  2.41k|      ++wildcard;
  915|  2.41k|      ++match;
  916|  2.41k|      --num;
  917|  2.41k|    }
  918|       |
  919|    193|  return (!num) || (*wildcard == *match);
  ------------------
  |  Branch (919:10): [True: 97, False: 96]
  |  Branch (919:20): [True: 11, False: 85]
  ------------------
  920|    658|}
whine_malloc_real:
  944|    275|{
  945|    275|  void *ret = calloc(1, size);
  946|       |  
  947|    275|  if (!ret)
  ------------------
  |  Branch (947:7): [True: 0, False: 275]
  ------------------
  948|      0|    my_syslog(LOG_ERR, _("failed to allocate %d bytes"), (int) size);
  ------------------
  |  |   91|      0|#  define _(S) (S)
  ------------------
  949|    275|  else if (daemon->log_malloc)
  ------------------
  |  |  169|    275|#define daemon dnsmasq_daemon
  ------------------
  |  Branch (949:12): [True: 0, False: 275]
  ------------------
  950|      0|    my_syslog(LOG_INFO, _("malloc: %s:%u %zu bytes at %x"), func, line, size, hash_ptr(ret));
  ------------------
  |  |   91|      0|#  define _(S) (S)
  ------------------
                  my_syslog(LOG_INFO, _("malloc: %s:%u %zu bytes at %x"), func, line, size, hash_ptr(ret));
  ------------------
  |  |  941|      0|#define hash_ptr(x) (((unsigned int)(((char *)(x)) - ((char *)NULL))) & 0xffffff)
  ------------------
  951|       |
  952|    275|  return ret;
  953|    275|}
free_real:
 1021|  29.7k|{
 1022|  29.7k|  if (ptr)
  ------------------
  |  Branch (1022:7): [True: 29.7k, False: 0]
  ------------------
 1023|  29.7k|    {
 1024|  29.7k|      if (daemon->log_malloc)
  ------------------
  |  |  169|  29.7k|#define daemon dnsmasq_daemon
  ------------------
  |  Branch (1024:11): [True: 0, False: 29.7k]
  ------------------
 1025|      0|	my_syslog(LOG_INFO, _("free: %s:%u block at %x"), func, line, hash_ptr(ptr));
  ------------------
  |  |   91|      0|#  define _(S) (S)
  ------------------
              	my_syslog(LOG_INFO, _("free: %s:%u block at %x"), func, line, hash_ptr(ptr));
  ------------------
  |  |  941|      0|#define hash_ptr(x) (((unsigned int)(((char *)(x)) - ((char *)NULL))) & 0xffffff)
  ------------------
 1026|       |  
 1027|  29.7k|      free(ptr);
 1028|  29.7k|    }
 1029|  29.7k|}
util.c:check_name:
  136|  1.31k|{
  137|       |  /* remove trailing . 
  138|       |     also fail empty string and label > 63 chars */
  139|  1.31k|  size_t dotgap = 0, wiresize = 0, l = strlen(in);
  140|  1.31k|  char c;
  141|  1.31k|  int nowhite = 0;
  142|  1.31k|  int idn_encode = 0;
  143|  1.31k|  int hasuscore = 0;
  144|  1.31k|  int hasucase = 0;
  145|       |  
  146|  1.31k|  if (l == 0)
  ------------------
  |  Branch (146:7): [True: 85, False: 1.23k]
  ------------------
  147|     85|    return 0;
  148|       |  
  149|  1.23k|  if (in[l-1] == '.')
  ------------------
  |  Branch (149:7): [True: 26, False: 1.20k]
  ------------------
  150|     26|    {
  151|     26|      in[l-1] = 0;
  152|     26|      nowhite = 1;
  153|     26|    }
  154|       |
  155|  21.5k|  for (; (c = *in); in++)
  ------------------
  |  Branch (155:10): [True: 20.8k, False: 692]
  ------------------
  156|  20.8k|    {
  157|  20.8k|      if (c == '.')
  ------------------
  |  Branch (157:11): [True: 898, False: 19.9k]
  ------------------
  158|    898|        {
  159|    898|	  wiresize += dotgap + 1;
  160|    898|	  dotgap = 0;
  161|    898|	}
  162|  19.9k|      else if (++dotgap > MAXLABEL)
  ------------------
  |  |   54|  19.9k|#define MAXLABEL        63              /* maximum length of domain label */
  ------------------
  |  Branch (162:16): [True: 180, False: 19.7k]
  ------------------
  163|    180|        return 0;
  164|  19.7k|      else if (isascii((unsigned char)c) && iscntrl((unsigned char)c)) 
  ------------------
  |  Branch (164:16): [True: 19.4k, False: 280]
  |  Branch (164:45): [True: 79, False: 19.4k]
  ------------------
  165|       |        /* iscntrl only gives expected results for ascii */
  166|     79|        return 0;
  167|  19.6k|      else if (!isascii((unsigned char)c))
  ------------------
  |  Branch (167:16): [True: 280, False: 19.4k]
  ------------------
  168|    280|#if !defined(HAVE_IDN) && !defined(HAVE_LIBIDN2)
  169|    280|        return 0;
  170|       |#else
  171|       |        idn_encode = 1;
  172|       |#endif
  173|  19.4k|      else if (c != ' ')
  ------------------
  |  Branch (173:16): [True: 15.4k, False: 3.98k]
  ------------------
  174|  15.4k|        {
  175|  15.4k|          nowhite = 1;
  176|       |#if defined(HAVE_LIBIDN2) && (!defined(IDN2_VERSION_NUMBER) || IDN2_VERSION_NUMBER < 0x02000003)
  177|       |          if (c == '_')
  178|       |            hasuscore = 1;
  179|       |#else
  180|  15.4k|          (void)hasuscore;
  181|  15.4k|#endif
  182|       |
  183|       |#if defined(HAVE_IDN) || defined(HAVE_LIBIDN2)
  184|       |          if (c >= 'A' && c <= 'Z')
  185|       |            hasucase = 1;
  186|       |#else
  187|  15.4k|          (void)hasucase;
  188|  15.4k|#endif
  189|  15.4k|        }
  190|  20.8k|    }
  191|       |
  192|    692|  if (!nowhite)
  ------------------
  |  Branch (192:7): [True: 76, False: 616]
  ------------------
  193|     76|    return 0;
  194|       |
  195|       |#if defined(HAVE_LIBIDN2) && (!defined(IDN2_VERSION_NUMBER) || IDN2_VERSION_NUMBER < 0x02000003)
  196|       |  /* Older libidn2 strips underscores, so don't do IDN processing
  197|       |     if the name has an underscore unless it also has non-ascii characters. */
  198|       |  idn_encode = idn_encode || (hasucase && !hasuscore);
  199|       |#else
  200|    616|  idn_encode = idn_encode || hasucase;
  ------------------
  |  Branch (200:16): [True: 0, False: 616]
  |  Branch (200:30): [True: 0, False: 616]
  ------------------
  201|    616|#endif
  202|       |
  203|       | /* length of final label and terminaton added */
  204|    616|  if (!idn_encode && wiresize + dotgap + 2 >  MAXDNAME)
  ------------------
  |  |   49|    616|#define MAXDNAME        255             /* Maximum size of a domain name in wire format */
  ------------------
  |  Branch (204:7): [True: 616, False: 0]
  |  Branch (204:22): [True: 0, False: 616]
  ------------------
  205|      0|    return 0; /* wire representation too long */
  206|       |
  207|    616|  return (idn_encode) ? 2 : 1;
  ------------------
  |  Branch (207:10): [True: 0, False: 616]
  ------------------
  208|    616|}

LLVMFuzzerTestOneInput:
  224|  1.02k|extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
  225|  1.02k|  FuzzedDataProvider provider(data, size);
  226|       |
  227|  1.02k|  std::vector<void *> allocs;
  228|  1.02k|  std::vector<std::string> strings;
  229|  1.02k|  strings.reserve(40);
  230|       |
  231|  1.02k|  int succ = init_daemon(provider, allocs, strings);
  232|  1.02k|  if (succ == 0) {
  ------------------
  |  Branch (232:7): [True: 1.02k, False: 0]
  ------------------
  233|  1.02k|    std::string t1_str = provider.ConsumeRandomLengthString(MAXDNAME);
  ------------------
  |  |   49|  1.02k|#define MAXDNAME        255             /* Maximum size of a domain name in wire format */
  ------------------
  234|  1.02k|    std::string t2_str = provider.ConsumeRandomLengthString(MAXDNAME);
  ------------------
  |  |   49|  1.02k|#define MAXDNAME        255             /* Maximum size of a domain name in wire format */
  ------------------
  235|  1.02k|    if (t1_str.empty() || t2_str.empty())
  ------------------
  |  Branch (235:9): [True: 315, False: 714]
  |  Branch (235:27): [True: 56, False: 658]
  ------------------
  236|    371|      goto cleanup;
  237|       |
  238|    658|    char *t1 = t1_str.data();
  239|    658|    char *t2 = t2_str.data();
  240|       |
  241|       |    // Util logic
  242|    658|    hostname_isequal(t1, t2);
  243|       |
  244|    658|    legal_hostname(t1);
  245|    658|    char *tmp = canonicalise(t2, NULL);
  246|    658|    if (tmp != NULL) {
  ------------------
  |  Branch (246:9): [True: 275, False: 383]
  ------------------
  247|    275|      free(tmp);
  ------------------
  |  | 1512|    275|#define free(x) free_real(__func__, __LINE__, (x))
  ------------------
  248|    275|    }
  249|       |
  250|    658|    char *tmp_out = (char *)malloc(30);
  251|    658|    if (tmp_out) {
  ------------------
  |  Branch (251:9): [True: 658, False: 0]
  ------------------
  252|    658|      int mac_type;
  253|    658|      parse_hex(t1, (unsigned char *)tmp_out, 30, NULL, NULL);
  254|    658|      parse_hex(t1, (unsigned char *)tmp_out, 30, NULL, &mac_type);
  255|    658|      free(tmp_out);
  ------------------
  |  | 1512|    658|#define free(x) free_real(__func__, __LINE__, (x))
  ------------------
  256|    658|    }
  257|       |
  258|    658|    wildcard_match(t1, t2);
  259|    658|    if (t1_str.size() < t2_str.size()) {
  ------------------
  |  Branch (259:9): [True: 109, False: 549]
  ------------------
  260|    109|      wildcard_matchn(t1, t2, t1_str.size());
  261|    549|    } else {
  262|    549|      wildcard_matchn(t1, t2, t2_str.size());
  263|    549|    }
  264|    658|    hostname_issubdomain(t1, t2);
  265|       |
  266|    658|    union all_addr addr1;
  267|    658|    memset(&addr1, 0, sizeof(union all_addr));
  268|    658|    is_name_synthetic(0, t1, &addr1);
  269|    658|  }
  270|       |
  271|  1.02k|cleanup:
  272|  1.02k|  for (void *p : allocs)
  ------------------
  |  Branch (272:16): [True: 27.7k, False: 1.02k]
  ------------------
  273|  27.7k|    free(p);
  ------------------
  |  | 1512|  27.7k|#define free(x) free_real(__func__, __LINE__, (x))
  ------------------
  274|       |  // Free daemon last since dnsmasq's free_real() dereferences it.
  275|  1.02k|  free(daemon);
  ------------------
  |  | 1512|  1.02k|#define free(x) free_real(__func__, __LINE__, (x))
  ------------------
  276|  1.02k|  daemon = NULL;
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
  277|       |
  278|  1.02k|  return 0;
  279|  1.02k|}
fuzz_util.cc:_ZL11init_daemonR18FuzzedDataProviderRNSt3__16vectorIPvNS1_9allocatorIS3_EEEERNS2_INS1_12basic_stringIcNS1_11char_traitsIcEENS4_IcEEEENS4_ISC_EEEE:
   27|  1.02k|                       std::vector<std::string> &strings) {
   28|  1.02k|  auto alloc = [&](size_t sz) -> void * {
   29|  1.02k|    void *p = calloc(1, sz);
   30|  1.02k|    if (p) allocs.push_back(p);
   31|  1.02k|    return p;
   32|  1.02k|  };
   33|       |
   34|  1.02k|  auto make_string = [&](size_t max_len) -> char * {
   35|  1.02k|    strings.push_back(provider.ConsumeRandomLengthString(max_len));
   36|  1.02k|    return strings.back().data();
   37|  1.02k|  };
   38|       |
   39|       |  // Allocate daemon separately (not via alloc) so it can be freed last.
   40|       |  // dnsmasq's free_real() dereferences daemon for metrics tracking.
   41|  1.02k|  daemon = (struct daemon *)calloc(1, sizeof(struct daemon));
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
   42|  1.02k|  if (!daemon) return -1;
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
  |  Branch (42:7): [True: 0, False: 1.02k]
  ------------------
   43|       |
   44|  1.02k|  daemon->max_ttl = provider.ConsumeIntegral<int>();
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
   45|  1.02k|  daemon->neg_ttl = provider.ConsumeIntegral<int>();
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
   46|  1.02k|  daemon->local_ttl = provider.ConsumeIntegral<int>();
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
   47|  1.02k|  daemon->min_cache_ttl = provider.ConsumeIntegral<int>();
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
   48|       |
   49|  1.02k|  daemon->namebuff = make_string(MAXDNAME);
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
                daemon->namebuff = make_string(MAXDNAME);
  ------------------
  |  |   49|  1.02k|#define MAXDNAME        255             /* Maximum size of a domain name in wire format */
  ------------------
   50|       |
   51|       |  // daemon->naptr
   52|  1.02k|  struct naptr *naptr_ptr = (struct naptr *)alloc(sizeof(struct naptr));
   53|  1.02k|  if (!naptr_ptr) return -1;
  ------------------
  |  Branch (53:7): [True: 0, False: 1.02k]
  ------------------
   54|  1.02k|  naptr_ptr->name = make_string(STR_SIZE);
  ------------------
  |  |   23|  1.02k|#define STR_SIZE 75
  ------------------
   55|  1.02k|  naptr_ptr->replace = make_string(STR_SIZE);
  ------------------
  |  |   23|  1.02k|#define STR_SIZE 75
  ------------------
   56|  1.02k|  naptr_ptr->regexp = make_string(STR_SIZE);
  ------------------
  |  |   23|  1.02k|#define STR_SIZE 75
  ------------------
   57|  1.02k|  naptr_ptr->services = make_string(STR_SIZE);
  ------------------
  |  |   23|  1.02k|#define STR_SIZE 75
  ------------------
   58|  1.02k|  naptr_ptr->flags = make_string(STR_SIZE);
  ------------------
  |  |   23|  1.02k|#define STR_SIZE 75
  ------------------
   59|  1.02k|  daemon->naptr = naptr_ptr;
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
   60|       |
   61|       |  // daemon->int_names
   62|  1.02k|  struct interface_name *int_namses =
   63|  1.02k|      (struct interface_name *)alloc(sizeof(struct interface_name));
   64|  1.02k|  if (!int_namses) return -1;
  ------------------
  |  Branch (64:7): [True: 0, False: 1.02k]
  ------------------
   65|  1.02k|  int_namses->name = make_string(STR_SIZE);
  ------------------
  |  |   23|  1.02k|#define STR_SIZE 75
  ------------------
   66|  1.02k|  int_namses->intr = make_string(STR_SIZE);
  ------------------
  |  |   23|  1.02k|#define STR_SIZE 75
  ------------------
   67|       |
   68|  1.02k|  struct addrlist *d_addrlist = (struct addrlist *)alloc(sizeof(struct addrlist));
   69|  1.02k|  if (!d_addrlist) return -1;
  ------------------
  |  Branch (69:7): [True: 0, False: 1.02k]
  ------------------
   70|  1.02k|  d_addrlist->flags = provider.ConsumeIntegral<int>();
   71|  1.02k|  d_addrlist->prefixlen = provider.ConsumeIntegral<int>();
   72|  1.02k|  int_namses->addr = d_addrlist;
   73|  1.02k|  daemon->int_names = int_namses;
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
   74|       |
   75|       |  // daemon->addrbuf
   76|  1.02k|  char *adbuf = (char *)alloc(200);
   77|  1.02k|  if (!adbuf) return -1;
  ------------------
  |  Branch (77:7): [True: 0, False: 1.02k]
  ------------------
   78|  1.02k|  daemon->addrbuff = adbuf;
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
   79|       |
   80|       |  // daemon->auth_zones
   81|  1.02k|  struct auth_zone *d_az = (struct auth_zone *)alloc(sizeof(struct auth_zone));
   82|  1.02k|  if (!d_az) return -1;
  ------------------
  |  Branch (82:7): [True: 0, False: 1.02k]
  ------------------
   83|  1.02k|  d_az->domain = make_string(STR_SIZE);
  ------------------
  |  |   23|  1.02k|#define STR_SIZE 75
  ------------------
   84|  1.02k|  daemon->auth_zones = d_az;
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
   85|       |
   86|       |  // daemon->mxnames
   87|  1.02k|  struct mx_srv_record *mx_srv_rec =
   88|  1.02k|      (struct mx_srv_record *)alloc(sizeof(struct mx_srv_record));
   89|  1.02k|  if (!mx_srv_rec) return -1;
  ------------------
  |  Branch (89:7): [True: 0, False: 1.02k]
  ------------------
   90|  1.02k|  mx_srv_rec->next = daemon->mxnames;
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
   91|  1.02k|  daemon->mxnames = mx_srv_rec;
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
   92|  1.02k|  mx_srv_rec->name = make_string(STR_SIZE);
  ------------------
  |  |   23|  1.02k|#define STR_SIZE 75
  ------------------
   93|  1.02k|  mx_srv_rec->target = make_string(STR_SIZE);
  ------------------
  |  |   23|  1.02k|#define STR_SIZE 75
  ------------------
   94|  1.02k|  mx_srv_rec->issrv = provider.ConsumeIntegral<int>();
   95|  1.02k|  mx_srv_rec->weight = provider.ConsumeIntegral<int>();
   96|  1.02k|  mx_srv_rec->priority = provider.ConsumeIntegral<int>();
   97|  1.02k|  mx_srv_rec->srvport = provider.ConsumeIntegral<int>();
   98|       |
   99|       |  // daemon->txt
  100|  1.02k|  struct txt_record *txt_record =
  101|  1.02k|      (struct txt_record *)alloc(sizeof(struct txt_record));
  102|  1.02k|  if (!txt_record) return -1;
  ------------------
  |  Branch (102:7): [True: 0, False: 1.02k]
  ------------------
  103|  1.02k|  txt_record->name = make_string(STR_SIZE);
  ------------------
  |  |   23|  1.02k|#define STR_SIZE 75
  ------------------
  104|  1.02k|  txt_record->txt = (unsigned char *)make_string(STR_SIZE);
  ------------------
  |  |   23|  1.02k|#define STR_SIZE 75
  ------------------
  105|  1.02k|  txt_record->class2 = provider.ConsumeIntegralInRange<short>(0, 9);
  106|  1.02k|  daemon->txt = txt_record;
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
  107|       |
  108|       |  // daemon->rr
  109|  1.02k|  struct txt_record *rr_record =
  110|  1.02k|      (struct txt_record *)alloc(sizeof(struct txt_record));
  111|  1.02k|  if (!rr_record) return -1;
  ------------------
  |  Branch (111:7): [True: 0, False: 1.02k]
  ------------------
  112|  1.02k|  rr_record->name = make_string(STR_SIZE);
  ------------------
  |  |   23|  1.02k|#define STR_SIZE 75
  ------------------
  113|  1.02k|  rr_record->txt = (unsigned char *)make_string(STR_SIZE);
  ------------------
  |  |   23|  1.02k|#define STR_SIZE 75
  ------------------
  114|  1.02k|  rr_record->class2 = provider.ConsumeIntegralInRange<short>(0, 9);
  115|  1.02k|  daemon->rr = rr_record;
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
  116|       |
  117|       |  // daemon->relay4
  118|  1.02k|  struct dhcp_relay *dr = (struct dhcp_relay *)alloc(sizeof(struct dhcp_relay));
  119|  1.02k|  if (!dr) return -1;
  ------------------
  |  Branch (119:7): [True: 0, False: 1.02k]
  ------------------
  120|  1.02k|  dr->interface = make_string(STR_SIZE);
  ------------------
  |  |   23|  1.02k|#define STR_SIZE 75
  ------------------
  121|  1.02k|  dr->next = NULL;
  122|  1.02k|  daemon->relay4 = dr;
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
  123|       |
  124|       |  // daemon->bridges
  125|  1.02k|  struct dhcp_bridge *db = (struct dhcp_bridge *)alloc(sizeof(struct dhcp_bridge));
  126|  1.02k|  if (!db) return -1;
  ------------------
  |  Branch (126:7): [True: 0, False: 1.02k]
  ------------------
  127|  1.02k|  {
  128|  1.02k|    std::string iface_str = provider.ConsumeRandomLengthString(IF_NAMESIZE - 1);
  129|  1.02k|    memcpy(db->iface, iface_str.c_str(), iface_str.size() + 1);
  130|  1.02k|  }
  131|       |
  132|  1.02k|  struct dhcp_bridge *db_alias =
  133|  1.02k|      (struct dhcp_bridge *)alloc(sizeof(struct dhcp_bridge));
  134|  1.02k|  if (!db_alias) return -1;
  ------------------
  |  Branch (134:7): [True: 0, False: 1.02k]
  ------------------
  135|  1.02k|  {
  136|  1.02k|    std::string alias_str = provider.ConsumeRandomLengthString(IF_NAMESIZE - 1);
  137|  1.02k|    memcpy(db_alias->iface, alias_str.c_str(), alias_str.size() + 1);
  138|  1.02k|  }
  139|  1.02k|  db->alias = db_alias;
  140|  1.02k|  daemon->bridges = db;
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
  141|       |
  142|       |  // daemon->if_names, if_addrs, if_except, dhcp_except, authinterface
  143|  1.02k|  auto make_iname = [&]() -> struct iname * {
  144|  1.02k|    struct iname *in = (struct iname *)alloc(sizeof(struct iname));
  145|  1.02k|    if (!in) return nullptr;
  146|  1.02k|    in->name = make_string(STR_SIZE);
  147|  1.02k|    in->next = NULL;
  148|  1.02k|    return in;
  149|  1.02k|  };
  150|       |
  151|  1.02k|  daemon->if_names = make_iname();
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
  152|  1.02k|  daemon->if_addrs = make_iname();
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
  153|  1.02k|  daemon->if_except = make_iname();
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
  154|  1.02k|  daemon->dhcp_except = make_iname();
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
  155|  1.02k|  daemon->authinterface = make_iname();
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
  156|  1.02k|  if (!daemon->if_names || !daemon->if_addrs || !daemon->if_except ||
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
                if (!daemon->if_names || !daemon->if_addrs || !daemon->if_except ||
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
                if (!daemon->if_names || !daemon->if_addrs || !daemon->if_except ||
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
  |  Branch (156:7): [True: 0, False: 1.02k]
  |  Branch (156:28): [True: 0, False: 1.02k]
  |  Branch (156:49): [True: 0, False: 1.02k]
  ------------------
  157|  1.02k|      !daemon->dhcp_except || !daemon->authinterface)
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
                    !daemon->dhcp_except || !daemon->authinterface)
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
  |  Branch (157:7): [True: 0, False: 1.02k]
  |  Branch (157:31): [True: 0, False: 1.02k]
  ------------------
  158|      0|    return -1;
  159|       |
  160|       |  // daemon->cnames
  161|  1.02k|  struct cname *cn = (struct cname *)alloc(sizeof(struct cname));
  162|  1.02k|  if (!cn) return -1;
  ------------------
  |  Branch (162:7): [True: 0, False: 1.02k]
  ------------------
  163|  1.02k|  cn->alias = make_string(STR_SIZE);
  ------------------
  |  |   23|  1.02k|#define STR_SIZE 75
  ------------------
  164|  1.02k|  cn->target = make_string(STR_SIZE);
  ------------------
  |  |   23|  1.02k|#define STR_SIZE 75
  ------------------
  165|  1.02k|  daemon->cnames = cn;
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
  166|       |
  167|       |  // daemon->ptr
  168|  1.02k|  struct ptr_record *ptr = (struct ptr_record *)alloc(sizeof(struct ptr_record));
  169|  1.02k|  if (!ptr) return -1;
  ------------------
  |  Branch (169:7): [True: 0, False: 1.02k]
  ------------------
  170|  1.02k|  ptr->name = make_string(STR_SIZE);
  ------------------
  |  |   23|  1.02k|#define STR_SIZE 75
  ------------------
  171|  1.02k|  daemon->ptr = ptr;
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
  172|       |
  173|       |  // daemon->dhcp
  174|  1.02k|  struct dhcp_context *dhcp_c =
  175|  1.02k|      (struct dhcp_context *)alloc(sizeof(struct dhcp_context));
  176|  1.02k|  if (!dhcp_c) return -1;
  ------------------
  |  Branch (176:7): [True: 0, False: 1.02k]
  ------------------
  177|  1.02k|  dhcp_c->next = NULL;
  178|  1.02k|  dhcp_c->current = NULL;
  179|  1.02k|  struct dhcp_netid *dhcp_c_netid =
  180|  1.02k|      (struct dhcp_netid *)alloc(sizeof(struct dhcp_netid));
  181|  1.02k|  if (!dhcp_c_netid) return -1;
  ------------------
  |  Branch (181:7): [True: 0, False: 1.02k]
  ------------------
  182|  1.02k|  dhcp_c_netid->net = make_string(STR_SIZE);
  ------------------
  |  |   23|  1.02k|#define STR_SIZE 75
  ------------------
  183|  1.02k|  dhcp_c->filter = dhcp_c_netid;
  184|  1.02k|  dhcp_c->template_interface = make_string(STR_SIZE);
  ------------------
  |  |   23|  1.02k|#define STR_SIZE 75
  ------------------
  185|  1.02k|  daemon->dhcp = dhcp_c;
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
  186|       |
  187|       |  // daemon->dhcp6
  188|  1.02k|  struct dhcp_context *dhcp6_c =
  189|  1.02k|      (struct dhcp_context *)alloc(sizeof(struct dhcp_context));
  190|  1.02k|  if (!dhcp6_c) return -1;
  ------------------
  |  Branch (190:7): [True: 0, False: 1.02k]
  ------------------
  191|  1.02k|  dhcp6_c->next = NULL;
  192|  1.02k|  dhcp6_c->current = NULL;
  193|  1.02k|  struct dhcp_netid *dhcp6_c_netid =
  194|  1.02k|      (struct dhcp_netid *)alloc(sizeof(struct dhcp_netid));
  195|  1.02k|  if (!dhcp6_c_netid) return -1;
  ------------------
  |  Branch (195:7): [True: 0, False: 1.02k]
  ------------------
  196|  1.02k|  dhcp6_c_netid->net = make_string(STR_SIZE);
  ------------------
  |  |   23|  1.02k|#define STR_SIZE 75
  ------------------
  197|  1.02k|  dhcp6_c->filter = dhcp6_c_netid;
  198|  1.02k|  dhcp6_c->template_interface = make_string(STR_SIZE);
  ------------------
  |  |   23|  1.02k|#define STR_SIZE 75
  ------------------
  199|  1.02k|  daemon->dhcp6 = dhcp6_c;
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
  200|       |
  201|  1.02k|  daemon->doing_dhcp6 = 1;
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
  202|       |
  203|       |  // daemon->dhcp_buffs
  204|  1.02k|  daemon->dhcp_buff = (char *)alloc(DHCP_BUFF_SZ);
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
                daemon->dhcp_buff = (char *)alloc(DHCP_BUFF_SZ);
  ------------------
  |  |   24|  1.02k|#define DHCP_BUFF_SZ 256
  ------------------
  205|  1.02k|  daemon->dhcp_buff2 = (char *)alloc(DHCP_BUFF_SZ);
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
                daemon->dhcp_buff2 = (char *)alloc(DHCP_BUFF_SZ);
  ------------------
  |  |   24|  1.02k|#define DHCP_BUFF_SZ 256
  ------------------
  206|  1.02k|  daemon->dhcp_buff3 = (char *)alloc(DHCP_BUFF_SZ);
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
                daemon->dhcp_buff3 = (char *)alloc(DHCP_BUFF_SZ);
  ------------------
  |  |   24|  1.02k|#define DHCP_BUFF_SZ 256
  ------------------
  207|  1.02k|  if (!daemon->dhcp_buff || !daemon->dhcp_buff2 || !daemon->dhcp_buff3)
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
                if (!daemon->dhcp_buff || !daemon->dhcp_buff2 || !daemon->dhcp_buff3)
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
                if (!daemon->dhcp_buff || !daemon->dhcp_buff2 || !daemon->dhcp_buff3)
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
  |  Branch (207:7): [True: 0, False: 1.02k]
  |  Branch (207:29): [True: 0, False: 1.02k]
  |  Branch (207:52): [True: 0, False: 1.02k]
  ------------------
  208|      0|    return -1;
  209|       |
  210|       |  // daemon->ignore_addr
  211|  1.02k|  struct bogus_addr *bb = (struct bogus_addr *)alloc(sizeof(struct bogus_addr));
  212|  1.02k|  if (!bb) return -1;
  ------------------
  |  Branch (212:7): [True: 0, False: 1.02k]
  ------------------
  213|  1.02k|  daemon->ignore_addr = bb;
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
  214|       |
  215|       |  // daemon->doctors
  216|  1.02k|  struct doctor *doctors = (struct doctor *)alloc(sizeof(struct doctor));
  217|  1.02k|  if (!doctors) return -1;
  ------------------
  |  Branch (217:7): [True: 0, False: 1.02k]
  ------------------
  218|  1.02k|  doctors->next = NULL;
  219|  1.02k|  daemon->doctors = doctors;
  ------------------
  |  |  169|  1.02k|#define daemon dnsmasq_daemon
  ------------------
  220|       |
  221|  1.02k|  return 0;
  222|  1.02k|}
fuzz_util.cc:_ZZL11init_daemonR18FuzzedDataProviderRNSt3__16vectorIPvNS1_9allocatorIS3_EEEERNS2_INS1_12basic_stringIcNS1_11char_traitsIcEENS4_IcEEEENS4_ISC_EEEEENK3$_1clEm:
   34|  28.8k|  auto make_string = [&](size_t max_len) -> char * {
   35|  28.8k|    strings.push_back(provider.ConsumeRandomLengthString(max_len));
   36|  28.8k|    return strings.back().data();
   37|  28.8k|  };
fuzz_util.cc:_ZZL11init_daemonR18FuzzedDataProviderRNSt3__16vectorIPvNS1_9allocatorIS3_EEEERNS2_INS1_12basic_stringIcNS1_11char_traitsIcEENS4_IcEEEENS4_ISC_EEEEENK3$_0clEm:
   28|  27.7k|  auto alloc = [&](size_t sz) -> void * {
   29|  27.7k|    void *p = calloc(1, sz);
   30|  27.7k|    if (p) allocs.push_back(p);
  ------------------
  |  Branch (30:9): [True: 27.7k, False: 0]
  ------------------
   31|  27.7k|    return p;
   32|  27.7k|  };
fuzz_util.cc:_ZZL11init_daemonR18FuzzedDataProviderRNSt3__16vectorIPvNS1_9allocatorIS3_EEEERNS2_INS1_12basic_stringIcNS1_11char_traitsIcEENS4_IcEEEENS4_ISC_EEEEENK3$_2clEv:
  143|  5.14k|  auto make_iname = [&]() -> struct iname * {
  144|  5.14k|    struct iname *in = (struct iname *)alloc(sizeof(struct iname));
  145|  5.14k|    if (!in) return nullptr;
  ------------------
  |  Branch (145:9): [True: 0, False: 5.14k]
  ------------------
  146|  5.14k|    in->name = make_string(STR_SIZE);
  ------------------
  |  |   23|  5.14k|#define STR_SIZE 75
  ------------------
  147|       |    in->next = NULL;
  148|  5.14k|    return in;
  149|  5.14k|  };

