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

legal_hostname:
  215|    520|{
  216|    520|  char c;
  217|    520|  int first;
  218|       |
  219|    520|  if (!check_name(name))
  ------------------
  |  Branch (219:7): [True: 221, False: 299]
  ------------------
  220|    221|    return 0;
  221|       |
  222|  1.70k|  for (first = 1; (c = *name); name++, first = 0)
  ------------------
  |  Branch (222:19): [True: 1.56k, False: 147]
  ------------------
  223|       |    /* check for legal char a-z A-Z 0-9 - _ . */
  224|  1.56k|    {
  225|  1.56k|      if ((c >= 'A' && c <= 'Z') ||
  ------------------
  |  Branch (225:12): [True: 842, False: 719]
  |  Branch (225:24): [True: 365, False: 477]
  ------------------
  226|  1.19k|	  (c >= 'a' && c <= 'z') ||
  ------------------
  |  Branch (226:5): [True: 366, False: 830]
  |  Branch (226:17): [True: 359, False: 7]
  ------------------
  227|    837|	  (c >= '0' && c <= '9'))
  ------------------
  |  Branch (227:5): [True: 627, False: 210]
  |  Branch (227:17): [True: 479, False: 148]
  ------------------
  228|  1.20k|	continue;
  229|       |
  230|    358|      if (!first && (c == '-' || c == '_'))
  ------------------
  |  Branch (230:11): [True: 253, False: 105]
  |  Branch (230:22): [True: 117, False: 136]
  |  Branch (230:34): [True: 89, False: 47]
  ------------------
  231|    206|	continue;
  232|       |      
  233|       |      /* end of hostname part */
  234|    152|      if (c == '.')
  ------------------
  |  Branch (234:11): [True: 12, False: 140]
  ------------------
  235|     12|	return 1;
  236|       |      
  237|    140|      return 0;
  238|    152|    }
  239|       |  
  240|    147|  return 1;
  241|    299|}
canonicalise:
  244|    520|{
  245|    520|  char *ret = NULL;
  246|    520|  int rc;
  247|       |  
  248|    520|  if (nomem)
  ------------------
  |  Branch (248:7): [True: 0, False: 520]
  ------------------
  249|      0|    *nomem = 0;
  250|       |  
  251|    520|  if (!(rc = check_name(in)))
  ------------------
  |  Branch (251:7): [True: 284, False: 236]
  ------------------
  252|    284|    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|    236|  (void)rc;
  284|    236|#endif
  285|       |  
  286|    236|  if ((ret = whine_malloc(strlen(in)+1)))
  ------------------
  |  | 1509|    236|#define whine_malloc(x) whine_malloc_real(__func__, __LINE__, (x))
  ------------------
  |  Branch (286:7): [True: 236, False: 0]
  ------------------
  287|    236|    strcpy(ret, in);
  288|      0|  else if (nomem)
  ------------------
  |  Branch (288:12): [True: 0, False: 0]
  ------------------
  289|      0|    *nomem = 1;
  290|       |
  291|    236|  return ret;
  292|    520|}
hostname_order:
  405|    158|{
  406|    158|  unsigned int c1, c2;
  407|       |  
  408|  3.92k|  do {
  409|  3.92k|    c1 = (unsigned char) *a++;
  410|  3.92k|    c2 = (unsigned char) *b++;
  411|       |    
  412|  3.92k|    if (c1 >= 'A' && c1 <= 'Z')
  ------------------
  |  Branch (412:9): [True: 1.91k, False: 2.01k]
  |  Branch (412:22): [True: 354, False: 1.55k]
  ------------------
  413|    354|      c1 += 'a' - 'A';
  414|  3.92k|    if (c2 >= 'A' && c2 <= 'Z')
  ------------------
  |  Branch (414:9): [True: 1.91k, False: 2.00k]
  |  Branch (414:22): [True: 364, False: 1.55k]
  ------------------
  415|    364|      c2 += 'a' - 'A';
  416|       |    
  417|  3.92k|    if (c1 < c2)
  ------------------
  |  Branch (417:9): [True: 54, False: 3.86k]
  ------------------
  418|     54|      return -1;
  419|  3.86k|    else if (c1 > c2)
  ------------------
  |  Branch (419:14): [True: 46, False: 3.82k]
  ------------------
  420|     46|      return 1;
  421|       |    
  422|  3.92k|  } while (c1);
  ------------------
  |  Branch (422:12): [True: 3.76k, False: 58]
  ------------------
  423|       |  
  424|     58|  return 0;
  425|    158|}
hostname_isequal:
  428|    520|{
  429|    520|  return strlen(a) == strlen(b) && hostname_order(a, b) == 0;
  ------------------
  |  Branch (429:10): [True: 158, False: 362]
  |  Branch (429:36): [True: 58, False: 100]
  ------------------
  430|    520|}
hostname_issubdomain:
  434|    520|{
  435|    520|  char *ap, *bp;
  436|    520|  unsigned int c1, c2;
  437|       |  
  438|       |  /* move to the end */
  439|  12.9k|  for (ap = a; *ap; ap++); 
  ------------------
  |  Branch (439:16): [True: 12.4k, False: 520]
  ------------------
  440|  16.6k|  for (bp = b; *bp; bp++);
  ------------------
  |  Branch (440:16): [True: 16.1k, False: 520]
  ------------------
  441|       |
  442|       |  /* anything is a subdomain of the root domain. */
  443|    520|  if (ap == a)
  ------------------
  |  Branch (443:7): [True: 23, False: 497]
  ------------------
  444|     23|    return (bp == b) ? 2 : 1;
  ------------------
  |  Branch (444:12): [True: 12, False: 11]
  ------------------
  445|       |  
  446|       |  /* b shorter than a */
  447|    497|  if ((bp - b) < (ap - a))
  ------------------
  |  Branch (447:7): [True: 214, False: 283]
  ------------------
  448|    214|    return 0;
  449|       |  
  450|    283|  do
  451|  3.36k|    {
  452|  3.36k|      c1 = (unsigned char) *(--ap);
  453|  3.36k|      c2 = (unsigned char) *(--bp);
  454|       |  
  455|  3.36k|       if (c1 >= 'A' && c1 <= 'Z')
  ------------------
  |  Branch (455:12): [True: 1.59k, False: 1.77k]
  |  Branch (455:25): [True: 535, False: 1.05k]
  ------------------
  456|    535|	 c1 += 'a' - 'A';
  457|  3.36k|       if (c2 >= 'A' && c2 <= 'Z')
  ------------------
  |  Branch (457:12): [True: 1.58k, False: 1.78k]
  |  Branch (457:25): [True: 546, False: 1.04k]
  ------------------
  458|    546|	 c2 += 'a' - 'A';
  459|       |
  460|  3.36k|       if (c1 != c2)
  ------------------
  |  Branch (460:12): [True: 201, False: 3.16k]
  ------------------
  461|    201|	 return 0;
  462|  3.36k|    } while (ap != a);
  ------------------
  |  Branch (462:14): [True: 3.08k, False: 82]
  ------------------
  463|       |
  464|     82|  if (bp == b)
  ------------------
  |  Branch (464:7): [True: 43, False: 39]
  ------------------
  465|     43|    return 2;
  466|       |
  467|     39|  if (*(--bp) == '.')
  ------------------
  |  Branch (467:7): [True: 2, False: 37]
  ------------------
  468|      2|    return 1;
  469|       |
  470|     37|  return 0;
  471|     39|}
parse_hex:
  614|  1.04k|{
  615|  1.04k|  int done = 0, mask = 0, i = 0;
  616|  1.04k|  char *r;
  617|       |    
  618|  1.04k|  if (mac_type)
  ------------------
  |  Branch (618:7): [True: 520, False: 520]
  ------------------
  619|    520|    *mac_type = 0;
  620|       |  
  621|  6.02k|  while (!done && (maxlen == -1 || i < maxlen))
  ------------------
  |  Branch (621:10): [True: 5.55k, False: 473]
  |  Branch (621:20): [True: 0, False: 5.55k]
  |  Branch (621:36): [True: 5.54k, False: 8]
  ------------------
  622|  5.54k|    {
  623|  13.5k|      for (r = in; *r != 0 && *r != ':' && *r != '-' && *r != ' '; r++)
  ------------------
  |  Branch (623:20): [True: 13.0k, False: 484]
  |  Branch (623:31): [True: 12.6k, False: 435]
  |  Branch (623:44): [True: 11.9k, False: 741]
  |  Branch (623:57): [True: 8.56k, False: 3.34k]
  ------------------
  624|  8.56k|	if (*r != '*' && !isxdigit((unsigned char)*r))
  ------------------
  |  Branch (624:6): [True: 7.92k, False: 646]
  |  Branch (624:19): [True: 546, False: 7.37k]
  ------------------
  625|    546|	  return -1;
  626|       |      
  627|  5.00k|      if (*r == 0)
  ------------------
  |  Branch (627:11): [True: 484, False: 4.51k]
  ------------------
  628|    484|	done = 1;
  629|       |      
  630|  5.00k|      if (r != in )
  ------------------
  |  Branch (630:11): [True: 734, False: 4.26k]
  ------------------
  631|    734|	{
  632|    734|	  if (*r == '-' && i == 0 && mac_type)
  ------------------
  |  Branch (632:8): [True: 221, False: 513]
  |  Branch (632:21): [True: 39, False: 182]
  |  Branch (632:31): [True: 0, False: 39]
  ------------------
  633|      0|	   {
  634|      0|	      *r = 0;
  635|      0|	      *mac_type = strtol(in, NULL, 16);
  636|      0|	      mac_type = NULL;
  637|      0|	   }
  638|    734|	  else
  639|    734|	    {
  640|    734|	      *r = 0;
  641|    734|	      if (strcmp(in, "*") == 0)
  ------------------
  |  Branch (641:12): [True: 309, False: 425]
  ------------------
  642|    309|		{
  643|    309|		  mask = (mask << 1) | 1;
  644|    309|		  i++;
  645|    309|		}
  646|    425|	      else
  647|    425|		{
  648|    425|		  int j, bytes = (1 + (r - in))/2;
  649|  2.21k|		  for (j = 0; j < bytes; j++)
  ------------------
  |  Branch (649:17): [True: 1.83k, False: 377]
  ------------------
  650|  1.83k|		    { 
  651|  1.83k|		      char sav;
  652|  1.83k|		      if (j < bytes - 1)
  ------------------
  |  Branch (652:13): [True: 1.43k, False: 406]
  ------------------
  653|  1.43k|			{
  654|  1.43k|			  sav = in[(j+1)*2];
  655|  1.43k|			  in[(j+1)*2] = 0;
  656|  1.43k|			}
  657|       |		      /* checks above allow mix of hexdigit and *, which
  658|       |			 is illegal. */
  659|  1.83k|		      if (strchr(&in[j*2], '*'))
  ------------------
  |  Branch (659:13): [True: 13, False: 1.82k]
  ------------------
  660|     13|			return -1;
  661|  1.82k|		      out[i] = strtol(&in[j*2], NULL, 16);
  662|  1.82k|		      mask = mask << 1;
  663|  1.82k|		      if (++i == maxlen)
  ------------------
  |  Branch (663:13): [True: 35, False: 1.78k]
  ------------------
  664|     35|			break; 
  665|  1.78k|		      if (j < bytes - 1)
  ------------------
  |  Branch (665:13): [True: 1.41k, False: 377]
  ------------------
  666|  1.41k|			in[(j+1)*2] = sav;
  667|  1.78k|		    }
  668|    425|		}
  669|    734|	    }
  670|    734|	}
  671|  4.98k|      in = r+1;
  672|  4.98k|    }
  673|       |  
  674|    481|  if (wildcard_mask)
  ------------------
  |  Branch (674:7): [True: 0, False: 481]
  ------------------
  675|      0|    *wildcard_mask = mask;
  676|       |
  677|    481|  return i;
  678|  1.04k|}
wildcard_match:
  896|    520|{
  897|  3.71k|  while (*wildcard && *match)
  ------------------
  |  Branch (897:10): [True: 3.61k, False: 96]
  |  Branch (897:23): [True: 3.51k, False: 102]
  ------------------
  898|  3.51k|    {
  899|  3.51k|      if (*wildcard == '*')
  ------------------
  |  Branch (899:11): [True: 37, False: 3.47k]
  ------------------
  900|     37|        return 1;
  901|       |
  902|  3.47k|      if (*wildcard != *match)
  ------------------
  |  Branch (902:11): [True: 285, False: 3.19k]
  ------------------
  903|    285|        return 0; 
  904|       |
  905|  3.19k|      ++wildcard;
  906|  3.19k|      ++match;
  907|  3.19k|    }
  908|       |
  909|    198|  return *wildcard == *match;
  910|    520|}
wildcard_matchn:
  914|    520|{
  915|  3.71k|  while (*wildcard && *match && num)
  ------------------
  |  Branch (915:10): [True: 3.61k, False: 96]
  |  Branch (915:23): [True: 3.51k, False: 102]
  |  Branch (915:33): [True: 3.51k, False: 0]
  ------------------
  916|  3.51k|    {
  917|  3.51k|      if (*wildcard == '*')
  ------------------
  |  Branch (917:11): [True: 37, False: 3.47k]
  ------------------
  918|     37|        return 1;
  919|       |
  920|  3.47k|      if (*wildcard != *match)
  ------------------
  |  Branch (920:11): [True: 285, False: 3.19k]
  ------------------
  921|    285|        return 0; 
  922|       |
  923|  3.19k|      ++wildcard;
  924|  3.19k|      ++match;
  925|  3.19k|      --num;
  926|  3.19k|    }
  927|       |
  928|    198|  return (!num) || (*wildcard == *match);
  ------------------
  |  Branch (928:10): [True: 98, False: 100]
  |  Branch (928:20): [True: 13, False: 87]
  ------------------
  929|    520|}
whine_malloc_real:
  953|    236|{
  954|    236|  void *ret = calloc(1, size);
  955|       |  
  956|    236|  if (!ret)
  ------------------
  |  Branch (956:7): [True: 0, False: 236]
  ------------------
  957|      0|    my_syslog(LOG_ERR, _("failed to allocate %d bytes"), (int) size);
  ------------------
  |  |   91|      0|#  define _(S) (S)
  ------------------
  958|    236|  else if (daemon->log_malloc)
  ------------------
  |  |  169|    236|#define daemon dnsmasq_daemon
  ------------------
  |  Branch (958:12): [True: 0, False: 236]
  ------------------
  959|      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));
  ------------------
  |  |  950|      0|#define hash_ptr(x) (((uintptr_t)(x)) & 0xffffff)
  ------------------
  960|       |
  961|    236|  return ret;
  962|    236|}
free_real:
 1030|  28.0k|{
 1031|  28.0k|  if (ptr)
  ------------------
  |  Branch (1031:7): [True: 28.0k, False: 0]
  ------------------
 1032|  28.0k|    {
 1033|  28.0k|      if (daemon->log_malloc)
  ------------------
  |  |  169|  28.0k|#define daemon dnsmasq_daemon
  ------------------
  |  Branch (1033:11): [True: 0, False: 28.0k]
  ------------------
 1034|      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));
  ------------------
  |  |  950|      0|#define hash_ptr(x) (((uintptr_t)(x)) & 0xffffff)
  ------------------
 1035|       |  
 1036|  28.0k|      free(ptr);
 1037|  28.0k|    }
 1038|  28.0k|}
util.c:check_name:
  136|  1.04k|{
  137|       |  /* remove trailing . 
  138|       |     also fail empty string and label > 63 chars */
  139|  1.04k|  size_t dotgap = 0, wiresize = 0, l = strlen(in);
  140|  1.04k|  char c;
  141|  1.04k|  int nowhite = 0;
  142|  1.04k|  int idn_encode = 0;
  143|  1.04k|  int hasuscore = 0;
  144|  1.04k|  int hasucase = 0;
  145|       |  
  146|  1.04k|  if (l == 0)
  ------------------
  |  Branch (146:7): [True: 81, False: 959]
  ------------------
  147|     81|    return 0;
  148|       |  
  149|    959|  if (in[l-1] == '.')
  ------------------
  |  Branch (149:7): [True: 30, False: 929]
  ------------------
  150|     30|    {
  151|     30|      in[l-1] = 0;
  152|     30|      nowhite = 1;
  153|     30|    }
  154|       |
  155|  17.0k|  for (; (c = *in); in++)
  ------------------
  |  Branch (155:10): [True: 16.4k, False: 613]
  ------------------
  156|  16.4k|    {
  157|  16.4k|      if (c == '.')
  ------------------
  |  Branch (157:11): [True: 2.05k, False: 14.4k]
  ------------------
  158|  2.05k|        {
  159|  2.05k|	  wiresize += dotgap + 1;
  160|  2.05k|	  dotgap = 0;
  161|  2.05k|	}
  162|  14.4k|      else if (++dotgap > MAXLABEL)
  ------------------
  |  |   54|  14.4k|#define MAXLABEL        63              /* maximum length of domain label */
  ------------------
  |  Branch (162:16): [True: 78, False: 14.3k]
  ------------------
  163|     78|        return 0;
  164|  14.3k|      else if (isascii((unsigned char)c) && iscntrl((unsigned char)c)) 
  ------------------
  |  Branch (164:16): [True: 14.1k, False: 201]
  |  Branch (164:45): [True: 67, False: 14.0k]
  ------------------
  165|       |        /* iscntrl only gives expected results for ascii */
  166|     67|        return 0;
  167|  14.2k|      else if (!isascii((unsigned char)c))
  ------------------
  |  Branch (167:16): [True: 201, False: 14.0k]
  ------------------
  168|    201|#if !defined(HAVE_IDN) && !defined(HAVE_LIBIDN2)
  169|    201|        return 0;
  170|       |#else
  171|       |        idn_encode = 1;
  172|       |#endif
  173|  14.0k|      else if (c != ' ')
  ------------------
  |  Branch (173:16): [True: 11.4k, False: 2.60k]
  ------------------
  174|  11.4k|        {
  175|  11.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|  11.4k|          (void)hasuscore;
  181|  11.4k|#endif
  182|       |
  183|       |#if defined(HAVE_IDN) || defined(HAVE_LIBIDN2)
  184|       |          if (c >= 'A' && c <= 'Z')
  185|       |            hasucase = 1;
  186|       |#else
  187|  11.4k|          (void)hasucase;
  188|  11.4k|#endif
  189|  11.4k|        }
  190|  16.4k|    }
  191|       |
  192|    613|  if (!nowhite)
  ------------------
  |  Branch (192:7): [True: 67, False: 546]
  ------------------
  193|     67|    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|    546|  idn_encode = idn_encode || hasucase;
  ------------------
  |  Branch (200:16): [True: 0, False: 546]
  |  Branch (200:30): [True: 0, False: 546]
  ------------------
  201|    546|#endif
  202|       |
  203|       | /* length of final label and terminaton added */
  204|    546|  if (!idn_encode && wiresize + dotgap + 2 >  MAXDNAME)
  ------------------
  |  |   49|    546|#define MAXDNAME        255             /* Maximum size of a domain name in wire format */
  ------------------
  |  Branch (204:7): [True: 546, False: 0]
  |  Branch (204:22): [True: 11, False: 535]
  ------------------
  205|     11|    return 0; /* wire representation too long */
  206|       |
  207|    535|  return (idn_encode) ? 2 : 1;
  ------------------
  |  Branch (207:10): [True: 0, False: 535]
  ------------------
  208|    546|}

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

