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

PowerDNS / pdns / 19741624072

27 Nov 2025 03:45PM UTC coverage: 73.086% (+0.02%) from 73.065%
19741624072

Pull #16570

github

web-flow
Merge 08a2cdb1d into f94a3f63f
Pull Request #16570: rec: rewrite all unwrap calls in web.rs

38523 of 63408 branches covered (60.75%)

Branch coverage included in aggregate %.

128044 of 164496 relevant lines covered (77.84%)

6531485.83 hits per line

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

76.47
/pdns/dnsdistdist/dnsdist-dnsquestion.cc
1
/*
2
 * This file is part of PowerDNS or dnsdist.
3
 * Copyright -- PowerDNS.COM B.V. and its contributors
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of version 2 of the GNU General Public License as
7
 * published by the Free Software Foundation.
8
 *
9
 * In addition, for the avoidance of any doubt, permission is granted to
10
 * link this program with OpenSSL and to (re)distribute the binaries
11
 * produced as the result of such linking.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
 */
22
#include "dnsdist.hh"
23
#include "dnsdist-configuration.hh"
24
#include "dnsdist-dnsparser.hh"
25

26
std::string DNSQuestion::getTrailingData() const
27
{
14✔
28
  // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
29
  const auto* message = reinterpret_cast<const char*>(this->getData().data());
14✔
30
  const uint16_t messageLen = getDNSPacketLength(message, this->getData().size());
14✔
31
  // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
32
  return {message + messageLen, this->getData().size() - messageLen};
14✔
33
}
14✔
34

35
bool DNSQuestion::setTrailingData(const std::string& tail)
36
{
15✔
37
  // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
38
  const char* message = reinterpret_cast<const char*>(this->data.data());
15✔
39
  const uint16_t messageLen = getDNSPacketLength(message, this->data.size());
15✔
40
  this->data.resize(messageLen);
15✔
41
  if (!tail.empty()) {
15✔
42
    if (!hasRoomFor(tail.size())) {
13✔
43
      return false;
2✔
44
    }
2✔
45
    this->data.insert(this->data.end(), tail.begin(), tail.end());
11✔
46
  }
11✔
47
  return true;
13✔
48
}
15✔
49

50
bool DNSQuestion::editHeader(const std::function<bool(dnsheader&)>& editFunction)
51
{
×
52
  if (data.size() < sizeof(dnsheader)) {
×
53
    throw std::runtime_error("Trying to access the dnsheader of a too small (" + std::to_string(data.size()) + ") DNSQuestion buffer");
×
54
  }
×
55
  return dnsdist::PacketMangling::editDNSHeaderFromPacket(data, editFunction);
×
56
}
×
57

58
DNSQuestion::DNSQuestion(InternalQueryState& ids_, PacketBuffer& data_) :
59
  data(data_), ids(ids_), ecsPrefixLength(ids.origRemote.sin4.sin_family == AF_INET ? dnsdist::configuration::getCurrentRuntimeConfiguration().d_ECSSourcePrefixV4 : dnsdist::configuration::getCurrentRuntimeConfiguration().d_ECSSourcePrefixV6), ecsOverride(dnsdist::configuration::getCurrentRuntimeConfiguration().d_ecsOverride)
4,294,981,067✔
60
{
4,545,332✔
61
}
4,545,332✔
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