is_name_synthetic:
   26|    603|{
   27|    603|  char *p;
   28|    603|  struct cond_domain *c = NULL;
   29|    603|  int prot = (flags & F_IPV6) ? AF_INET6 : AF_INET;
  ------------------
  |  |  523|    603|#define F_IPV6      (1u<<8)
  ------------------
  |  Branch (29:14): [True: 0, False: 603]
  ------------------
   30|    603|  union all_addr addr;
   31|       |  
   32|    603|  for (c = daemon->synth_domains; c; c = c->next)
  ------------------
  |  |  169|    603|#define daemon dnsmasq_daemon
  ------------------
  |  Branch (32:35): [True: 0, False: 603]
  ------------------
   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|    603|  return 0;
  150|    603|}

legal_hostname:
  215|    603|{
  216|    603|  char c;
  217|    603|  int first;
  218|       |
  219|    603|  if (!check_name(name))
  ------------------
  |  Branch (219:7): [True: 261, False: 342]
  ------------------
  220|    261|    return 0;
  221|       |
  222|  1.90k|  for (first = 1; (c = *name); name++, first = 0)
  ------------------
  |  Branch (222:19): [True: 1.73k, False: 174]
  ------------------
  223|       |    /* check for legal char a-z A-Z 0-9 - _ . */
  224|  1.73k|    {
  225|  1.73k|      if ((c >= 'A' && c <= 'Z') ||
  ------------------
  |  Branch (225:12): [True: 938, False: 796]
  |  Branch (225:24): [True: 412, False: 526]
  ------------------
  226|  1.32k|	  (c >= 'a' && c <= 'z') ||
  ------------------
  |  Branch (226:5): [True: 379, False: 943]
  |  Branch (226:17): [True: 374, False: 5]
  ------------------
  227|    948|	  (c >= '0' && c <= '9'))
  ------------------
  |  Branch (227:5): [True: 712, False: 236]
  |  Branch (227:17): [True: 533, False: 179]
  ------------------
  228|  1.31k|	continue;
  229|       |
  230|    415|      if (!first && (c == '-' || c == '_'))
  ------------------
  |  Branch (230:11): [True: 311, False: 104]
  |  Branch (230:22): [True: 116, False: 195]
  |  Branch (230:34): [True: 131, False: 64]
  ------------------
  231|    247|	continue;
  232|       |      
  233|       |      /* end of hostname part */
  234|    168|      if (c == '.')
  ------------------
  |  Branch (234:11): [True: 12, False: 156]
  ------------------
  235|     12|	return 1;
  236|       |      
  237|    156|      return 0;
  238|    168|    }
  239|       |  
  240|    174|  return 1;
  241|    342|}
canonicalise:
  244|    603|{
  245|    603|  char *ret = NULL;
  246|    603|  int rc;
  247|       |  
  248|    603|  if (nomem)
  ------------------
  |  Branch (248:7): [True: 0, False: 603]
  ------------------
  249|      0|    *nomem = 0;
  250|       |  
  251|    603|  if (!(rc = check_name(in)))
  ------------------
  |  Branch (251:7): [True: 312, False: 291]
  ------------------
  252|    312|    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|    291|  (void)rc;
  284|    291|#endif
  285|       |  
  286|    291|  if ((ret = whine_malloc(strlen(in)+1)))
  ------------------
  |  | 1508|    291|#define whine_malloc(x) whine_malloc_real(__func__, __LINE__, (x))
  ------------------
  |  Branch (286:7): [True: 291, False: 0]
  ------------------
  287|    291|    strcpy(ret, in);
  288|      0|  else if (nomem)
  ------------------
  |  Branch (288:12): [True: 0, False: 0]
  ------------------
  289|      0|    *nomem = 1;
  290|       |
  291|    291|  return ret;
  292|    603|}
hostname_order:
  405|    168|{
  406|    168|  unsigned int c1, c2;
  407|       |  
  408|  2.74k|  do {
  409|  2.74k|    c1 = (unsigned char) *a++;
  410|  2.74k|    c2 = (unsigned char) *b++;
  411|       |    
  412|  2.74k|    if (c1 >= 'A' && c1 <= 'Z')
  ------------------
  |  Branch (412:9): [True: 1.51k, False: 1.22k]
  |  Branch (412:22): [True: 379, False: 1.13k]
  ------------------
  413|    379|      c1 += 'a' - 'A';
  414|  2.74k|    if (c2 >= 'A' && c2 <= 'Z')
  ------------------
  |  Branch (414:9): [True: 1.52k, False: 1.21k]
  |  Branch (414:22): [True: 392, False: 1.13k]
  ------------------
  415|    392|      c2 += 'a' - 'A';
  416|       |    
  417|  2.74k|    if (c1 < c2)
  ------------------
  |  Branch (417:9): [True: 60, False: 2.68k]
  ------------------
  418|     60|      return -1;
  419|  2.68k|    else if (c1 > c2)
  ------------------
  |  Branch (419:14): [True: 52, False: 2.62k]
  ------------------
  420|     52|      return 1;
  421|       |    
  422|  2.74k|  } while (c1);
  ------------------
  |  Branch (422:12): [True: 2.57k, False: 56]
  ------------------
  423|       |  
  424|     56|  return 0;
  425|    168|}
hostname_isequal:
  428|    603|{
  429|    603|  return strlen(a) == strlen(b) && hostname_order(a, b) == 0;
  ------------------
  |  Branch (429:10): [True: 168, False: 435]
  |  Branch (429:36): [True: 56, False: 112]
  ------------------
  430|    603|}
hostname_issubdomain:
  434|    603|{
  435|    603|  char *ap, *bp;
  436|    603|  unsigned int c1, c2;
  437|       |  
  438|       |  /* move to the end */
  439|  16.4k|  for (ap = a; *ap; ap++); 
  ------------------
  |  Branch (439:16): [True: 15.8k, False: 603]
  ------------------
  440|  27.3k|  for (bp = b; *bp; bp++);
  ------------------
  |  Branch (440:16): [True: 26.7k, False: 603]
  ------------------
  441|       |
  442|       |  /* a shorter than b */
  443|    603|  if ((ap - a) < (bp - b))
  ------------------
  |  Branch (443:7): [True: 180, False: 423]
  ------------------
  444|    180|    return 0;
  445|       |
  446|    423|  do
  447|  2.71k|    {
  448|  2.71k|      c1 = (unsigned char) *(--ap);
  449|  2.71k|      c2 = (unsigned char) *(--bp);
  450|       |  
  451|  2.71k|       if (c1 >= 'A' && c1 <= 'Z')
  ------------------
  |  Branch (451:12): [True: 1.39k, False: 1.31k]
  |  Branch (451:25): [True: 502, False: 890]
  ------------------
  452|    502|	 c1 += 'a' - 'A';
  453|  2.71k|       if (c2 >= 'A' && c2 <= 'Z')
  ------------------
  |  Branch (453:12): [True: 1.38k, False: 1.32k]
  |  Branch (453:25): [True: 497, False: 892]
  ------------------
  454|    497|	 c2 += 'a' - 'A';
  455|       |
  456|  2.71k|       if (c1 != c2)
  ------------------
  |  Branch (456:12): [True: 321, False: 2.38k]
  ------------------
  457|    321|	 return 0;
  458|  2.71k|    } while (bp != b);
  ------------------
  |  Branch (458:14): [True: 2.28k, False: 102]
  ------------------
  459|       |
  460|    102|  if (ap == a)
  ------------------
  |  Branch (460:7): [True: 53, False: 49]
  ------------------
  461|     53|    return 2;
  462|       |
  463|     49|  if (*(--ap) == '.')
  ------------------
  |  Branch (463:7): [True: 2, False: 47]
  ------------------
  464|      2|    return 1;
  465|       |
  466|     47|  return 0;
  467|     49|}
parse_hex:
  611|  1.20k|{
  612|  1.20k|  int done = 0, mask = 0, i = 0;
  613|  1.20k|  char *r;
  614|       |    
  615|  1.20k|  if (mac_type)
  ------------------
  |  Branch (615:7): [True: 603, False: 603]
  ------------------
  616|    603|    *mac_type = 0;
  617|       |  
  618|  9.11k|  while (!done && (maxlen == -1 || i < maxlen))
  ------------------
  |  Branch (618:10): [True: 8.56k, False: 541]
  |  Branch (618:20): [True: 0, False: 8.56k]
  |  Branch (618:36): [True: 8.56k, False: 6]
  ------------------
  619|  8.56k|    {
  620|  18.5k|      for (r = in; *r != 0 && *r != ':' && *r != '-' && *r != ' '; r++)
  ------------------
  |  Branch (620:20): [True: 18.0k, False: 551]
  |  Branch (620:31): [True: 17.5k, False: 469]
  |  Branch (620:44): [True: 16.7k, False: 850]
  |  Branch (620:57): [True: 10.6k, False: 6.04k]
  ------------------
  621|  10.6k|	if (*r != '*' && !isxdigit((unsigned char)*r))
  ------------------
  |  Branch (621:6): [True: 10.0k, False: 622]
  |  Branch (621:19): [True: 649, False: 9.40k]
  ------------------
  622|    649|	  return -1;
  623|       |      
  624|  7.91k|      if (*r == 0)
  ------------------
  |  Branch (624:11): [True: 551, False: 7.36k]
  ------------------
  625|    551|	done = 1;
  626|       |      
  627|  7.91k|      if (r != in )
  ------------------
  |  Branch (627:11): [True: 1.12k, False: 6.78k]
  ------------------
  628|  1.12k|	{
  629|  1.12k|	  if (*r == '-' && i == 0 && mac_type)
  ------------------
  |  Branch (629:8): [True: 261, False: 864]
  |  Branch (629:21): [True: 37, False: 224]
  |  Branch (629:31): [True: 0, False: 37]
  ------------------
  630|      0|	   {
  631|      0|	      *r = 0;
  632|      0|	      *mac_type = strtol(in, NULL, 16);
  633|      0|	      mac_type = NULL;
  634|      0|	   }
  635|  1.12k|	  else
  636|  1.12k|	    {
  637|  1.12k|	      *r = 0;
  638|  1.12k|	      if (strcmp(in, "*") == 0)
  ------------------
  |  Branch (638:12): [True: 417, False: 708]
  ------------------
  639|    417|		{
  640|    417|		  mask = (mask << 1) | 1;
  641|    417|		  i++;
  642|    417|		}
  643|    708|	      else
  644|    708|		{
  645|    708|		  int j, bytes = (1 + (r - in))/2;
  646|  3.22k|		  for (j = 0; j < bytes; j++)
  ------------------
  |  Branch (646:17): [True: 2.56k, False: 664]
  ------------------
  647|  2.56k|		    { 
  648|  2.56k|		      char sav;
  649|  2.56k|		      if (j < bytes - 1)
  ------------------
  |  Branch (649:13): [True: 1.87k, False: 693]
  ------------------
  650|  1.87k|			{
  651|  1.87k|			  sav = in[(j+1)*2];
  652|  1.87k|			  in[(j+1)*2] = 0;
  653|  1.87k|			}
  654|       |		      /* checks above allow mix of hexdigit and *, which
  655|       |			 is illegal. */
  656|  2.56k|		      if (strchr(&in[j*2], '*'))
  ------------------
  |  Branch (656:13): [True: 10, False: 2.55k]
  ------------------
  657|     10|			return -1;
  658|  2.55k|		      out[i] = strtol(&in[j*2], NULL, 16);
  659|  2.55k|		      mask = mask << 1;
  660|  2.55k|		      if (++i == maxlen)
  ------------------
  |  Branch (660:13): [True: 34, False: 2.52k]
  ------------------
  661|     34|			break; 
  662|  2.52k|		      if (j < bytes - 1)
  ------------------
  |  Branch (662:13): [True: 1.85k, False: 664]
  ------------------
  663|  1.85k|			in[(j+1)*2] = sav;
  664|  2.52k|		    }
  665|    708|		}
  666|  1.12k|	    }
  667|  1.12k|	}
  668|  7.90k|      in = r+1;
  669|  7.90k|    }
  670|       |  
  671|    547|  if (wildcard_mask)
  ------------------
  |  Branch (671:7): [True: 0, False: 547]
  ------------------
  672|      0|    *wildcard_mask = mask;
  673|       |
  674|    547|  return i;
  675|  1.20k|}
wildcard_match:
  887|    603|{
  888|  2.95k|  while (*wildcard && *match)
  ------------------
  |  Branch (888:10): [True: 2.86k, False: 88]
  |  Branch (888:23): [True: 2.75k, False: 108]
  ------------------
  889|  2.75k|    {
  890|  2.75k|      if (*wildcard == '*')
  ------------------
  |  Branch (890:11): [True: 42, False: 2.71k]
  ------------------
  891|     42|        return 1;
  892|       |
  893|  2.71k|      if (*wildcard != *match)
  ------------------
  |  Branch (893:11): [True: 365, False: 2.34k]
  ------------------
  894|    365|        return 0; 
  895|       |
  896|  2.34k|      ++wildcard;
  897|  2.34k|      ++match;
  898|  2.34k|    }
  899|       |
  900|    196|  return *wildcard == *match;
  901|    603|}
wildcard_matchn:
  905|    603|{
  906|  2.95k|  while (*wildcard && *match && num)
  ------------------
  |  Branch (906:10): [True: 2.86k, False: 88]
  |  Branch (906:23): [True: 2.75k, False: 108]
  |  Branch (906:33): [True: 2.75k, False: 0]
  ------------------
  907|  2.75k|    {
  908|  2.75k|      if (*wildcard == '*')
  ------------------
  |  Branch (908:11): [True: 42, False: 2.71k]
  ------------------
  909|     42|        return 1;
  910|       |
  911|  2.71k|      if (*wildcard != *match)
  ------------------
  |  Branch (911:11): [True: 365, False: 2.34k]
  ------------------
  912|    365|        return 0; 
  913|       |
  914|  2.34k|      ++wildcard;
  915|  2.34k|      ++match;
  916|  2.34k|      --num;
  917|  2.34k|    }
  918|       |
  919|    196|  return (!num) || (*wildcard == *match);
  ------------------
  |  Branch (919:10): [True: 110, False: 86]
  |  Branch (919:20): [True: 6, False: 80]
  ------------------
  920|    603|}
whine_malloc_real:
  944|    291|{
  945|    291|  void *ret = calloc(1, size);
  946|       |  
  947|    291|  if (!ret)
  ------------------
  |  Branch (947:7): [True: 0, False: 291]
  ------------------
  948|      0|    my_syslog(LOG_ERR, _("failed to allocate %d bytes"), (int) size);
  ------------------
  |  |   91|      0|#  define _(S) (S)
  ------------------
  949|    291|  else if (daemon->log_malloc)
  ------------------
  |  |  169|    291|#define daemon dnsmasq_daemon
  ------------------
  |  Branch (949:12): [True: 0, False: 291]
  ------------------
  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|    291|  return ret;
  953|    291|}
free_real:
 1021|  27.8k|{
 1022|  27.8k|  if (ptr)
  ------------------
  |  Branch (1022:7): [True: 27.8k, False: 0]
  ------------------
 1023|  27.8k|    {
 1024|  27.8k|      if (daemon->log_malloc)
  ------------------
  |  |  169|  27.8k|#define daemon dnsmasq_daemon
  ------------------
  |  Branch (1024:11): [True: 0, False: 27.8k]
  ------------------
 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|  27.8k|      free(ptr);
 1028|  27.8k|    }
 1029|  27.8k|}
util.c:check_name:
  136|  1.20k|{
  137|       |  /* remove trailing . 
  138|       |     also fail empty string and label > 63 chars */
  139|  1.20k|  size_t dotgap = 0, wiresize = 0, l = strlen(in);
  140|  1.20k|  char c;
  141|  1.20k|  int nowhite = 0;
  142|  1.20k|  int idn_encode = 0;
  143|  1.20k|  int hasuscore = 0;
  144|  1.20k|  int hasucase = 0;
  145|       |  
  146|  1.20k|  if (l == 0)
  ------------------
  |  Branch (146:7): [True: 61, False: 1.14k]
  ------------------
  147|     61|    return 0;
  148|       |  
  149|  1.14k|  if (in[l-1] == '.')
  ------------------
  |  Branch (149:7): [True: 41, False: 1.10k]
  ------------------
  150|     41|    {
  151|     41|      in[l-1] = 0;
  152|     41|      nowhite = 1;
  153|     41|    }
  154|       |
  155|  20.8k|  for (; (c = *in); in++)
  ------------------
  |  Branch (155:10): [True: 20.1k, False: 714]
  ------------------
  156|  20.1k|    {
  157|  20.1k|      if (c == '.')
  ------------------
  |  Branch (157:11): [True: 2.07k, False: 18.0k]
  ------------------
  158|  2.07k|        {
  159|  2.07k|	  wiresize += dotgap + 1;
  160|  2.07k|	  dotgap = 0;
  161|  2.07k|	}
  162|  18.0k|      else if (++dotgap > MAXLABEL)
  ------------------
  |  |   54|  18.0k|#define MAXLABEL        63              /* maximum length of domain label */
  ------------------
  |  Branch (162:16): [True: 130, False: 17.9k]
  ------------------
  163|    130|        return 0;
  164|  17.9k|      else if (isascii((unsigned char)c) && iscntrl((unsigned char)c)) 
  ------------------
  |  Branch (164:16): [True: 17.6k, False: 236]
  |  Branch (164:45): [True: 65, False: 17.6k]
  ------------------
  165|       |        /* iscntrl only gives expected results for ascii */
  166|     65|        return 0;
  167|  17.8k|      else if (!isascii((unsigned char)c))
  ------------------
  |  Branch (167:16): [True: 236, False: 17.6k]
  ------------------
  168|    236|#if !defined(HAVE_IDN) && !defined(HAVE_LIBIDN2)
  169|    236|        return 0;
  170|       |#else
  171|       |        idn_encode = 1;
  172|       |#endif
  173|  17.6k|      else if (c != ' ')
  ------------------
  |  Branch (173:16): [True: 12.9k, False: 4.60k]
  ------------------
  174|  12.9k|        {
  175|  12.9k|          nowhite = 1;
  176|       |#if defined(HAVE_LIBIDN2) && (!defined(IDN2_VERSION_NUMBER) || IDN2_VERSION_NUMBER < 0x02000003)
  177|       |          if (c == '_')
  178|       |            hasuscore = 1;
  179|       |#else
  180|  12.9k|          (void)hasuscore;
  181|  12.9k|#endif
  182|       |
  183|       |#if defined(HAVE_IDN) || defined(HAVE_LIBIDN2)
  184|       |          if (c >= 'A' && c <= 'Z')
  185|       |            hasucase = 1;
  186|       |#else
  187|  12.9k|          (void)hasucase;
  188|  12.9k|#endif
  189|  12.9k|        }
  190|  20.1k|    }
  191|       |
  192|    714|  if (!nowhite)
  ------------------
  |  Branch (192:7): [True: 74, False: 640]
  ------------------
  193|     74|    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|    640|  idn_encode = idn_encode || hasucase;
  ------------------
  |  Branch (200:16): [True: 0, False: 640]
  |  Branch (200:30): [True: 0, False: 640]
  ------------------
  201|    640|#endif
  202|       |
  203|       | /* length of final label and terminaton added */
  204|    640|  if (!idn_encode && wiresize + dotgap + 2 >  MAXDNAME)
  ------------------
  |  |   49|    640|#define MAXDNAME        255             /* Maximum size of a domain name in wire format */
  ------------------
  |  Branch (204:7): [True: 640, False: 0]
  |  Branch (204:22): [True: 7, False: 633]
  ------------------
  205|      7|    return 0; /* wire representation too long */
  206|       |
  207|    633|  return (idn_encode) ? 2 : 1;
  ------------------
  |  Branch (207:10): [True: 0, False: 633]
  ------------------
  208|    640|}

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

