• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PowerDNS / pdns / 12595591960

03 Jan 2025 09:27AM UTC coverage: 62.774% (+2.5%) from 60.245%
12595591960

Pull #15008

github

web-flow
Merge c2a2749d3 into 788f396a7
Pull Request #15008: Do not follow CNAME records for ANY or CNAME queries

30393 of 78644 branches covered (38.65%)

Branch coverage included in aggregate %.

105822 of 138350 relevant lines covered (76.49%)

4613078.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.94
/pdns/recursordist/sortlist.cc
1
#include "sortlist.hh"
2
#include "dnsrecords.hh"
3

4
void SortList::clear()
5
{
×
6
  d_sortlist.clear();
×
7
}
×
8

9
int SortList::getMaxOrder(const Netmask& formask) const
10
{
1✔
11
  int order = 0;
1✔
12

13
  const auto* place = d_sortlist.lookup(formask);
1✔
14
  if (place != nullptr && place->first == formask) {
1!
15
    for (const auto& node_order : place->second.d_orders) {
×
16
      order = std::max(order, node_order.second);
×
17
    }
×
18
  }
×
19

20
  return order;
1✔
21
}
1✔
22

23
void SortList::addEntry(const Netmask& covers, const Netmask& answermask, int order)
24
{
8✔
25
  if (order < 0) {
8!
26
    order = getMaxOrder(covers);
×
27
    ++order;
×
28
  }
×
29
  //  cout<<"Adding for netmask "<<formask.toString()<<" the order instruction that "<<valmask.toString()<<" is order "<<order<<endl;
30
  d_sortlist.insert(covers).second.d_orders.insert(answermask).second = order;
8✔
31
}
8✔
32

33
std::unique_ptr<SortListOrderCmp> SortList::getOrderCmp(const ComboAddress& who) const
34
{
2,263✔
35
  if (!d_sortlist.match(who)) {
2,263✔
36
    return {};
2,262✔
37
  }
2,262✔
38
  const auto* fnd = d_sortlist.lookup(who);
1✔
39
  //  cerr<<"Returning sort order for "<<who.toString()<<", have "<<fnd->second.d_orders.size()<<" entries"<<endl;
40
  return make_unique<SortListOrderCmp>(fnd->second);
1✔
41
}
2,263✔
42

43
// call this with **stable_sort**
44
bool SortListOrderCmp::operator()(const DNSRecord& lhs, const DNSRecord& rhs) const
45
{
11✔
46
  bool aAddr = (lhs.d_type == QType::A || lhs.d_type == QType::AAAA);
11!
47
  bool bAddr = (rhs.d_type == QType::A || rhs.d_type == QType::AAAA);
11!
48

49
  // anything address related is always 'larger', rest is equal
50
  if (aAddr && !bAddr) {
11✔
51
    return false;
7✔
52
  }
7✔
53
  if (!aAddr && bAddr) {
4!
54
    return true;
×
55
  }
×
56
  if (!aAddr && !bAddr) {
4!
57
    return false;
1✔
58
  }
1✔
59

60
  int aOrder = std::numeric_limits<int>::max();
3✔
61
  int bOrder = aOrder;
3✔
62

63
  ComboAddress laddr = getAddr(lhs);
3✔
64
  ComboAddress raddr = getAddr(rhs);
3✔
65

66
  if (d_slo.d_orders.match(laddr)) {
3!
67
    aOrder = d_slo.d_orders.lookup(laddr)->second;
3✔
68
  }
3✔
69
  if (d_slo.d_orders.match(raddr)) {
3✔
70
    bOrder = d_slo.d_orders.lookup(raddr)->second;
1✔
71
  }
1✔
72
  return aOrder < bOrder;
3✔
73
}
4✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc