Skip to content

Commit

Permalink
geoipbackend: use const_iterator
Browse files Browse the repository at this point in the history
==8618==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7ffd8c5a1420 at pc 0x55bee0a5d899 bp 0x7ffd8c5a0710 sp 0x7ffd8c5a0708
READ of size 1 at 0x7ffd8c5a1420 thread T0
    #0 0x55bee0a5d898 in YAML::Node::begin() const /usr/include/yaml-cpp/node/impl.h:284:8
    #1 0x55bee0a3f2f0 in GeoIPBackend::initialize() /opt/project/modules/geoipbackend/geoipbackend.cc:163:27
    #2 0x55bee0a3d0d3 in GeoIPBackend::GeoIPBackend(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /opt/project/modules/geoipbackend/geoipbackend.cc:86:5
    #3 0x55bee0a784eb in GeoIPFactory::make(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /opt/project/modules/geoipbackend/geoipbackend.cc:1008:16
    #4 0x55bedff6cb18 in BackendMakerClass::all(bool) /opt/project/pdns/dnsbackend.cc:200:46
    #5 0x55bee07d3abe in UeberBackend::UeberBackend(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /opt/project/pdns/ueberbackend.cc:479:28
    #6 0x55bee060579c in PacketHandler::PacketHandler() /opt/project/pdns/packethandler.cc:65:32
    #7 0x55bedfee1748 in std::unique_ptr<PacketHandler, std::default_delete<PacketHandler> > make_unique<PacketHandler>() /opt/project/pdns/./misc.hh:571:35
    #8 0x55bee079376d in TCPNameserver::go() /opt/project/pdns/tcpreceiver.cc:85:9
    #9 0x55bedfecf7b7 in mainthread() /opt/project/pdns/common_startup.cc:656:7
    #10 0x55bee0655f67 in main /opt/project/pdns/receiver.cc:654:5
    #11 0x7f374b4b809a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
    #12 0x55bedfc9a989 in _start (/opt/pdns-auth/sbin/pdns_server+0x2736989)

Address 0x7ffd8c5a1420 is located in stack of thread T0 at offset 3040 in frame
    #0 0x55bee0a3d5ef in GeoIPBackend::initialize() /opt/project/modules/geoipbackend/geoipbackend.cc:115
  • Loading branch information
Habbie committed Jan 7, 2021
1 parent f061d15 commit 1a2d029
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions modules/geoipbackend/geoipbackend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ void GeoIPBackend::initialize() {
global_custom_mapping = mapping.as<map<std::string, std::string>>();
}

for(YAML::Node domain : config["domains"]) {
for(YAML::const_iterator _domain = config["domains"].begin(); _domain != config["domains"].end(); _domain++) {
const auto& domain = *_domain;
GeoIPDomain dom;
dom.id = tmp_domains.size();
dom.domain = DNSName(domain["domain"].as<string>());
Expand All @@ -160,8 +161,8 @@ void GeoIPBackend::initialize() {
DNSName qname = DNSName(recs->first.as<string>());
vector<GeoIPDNSResourceRecord> rrs;

for(YAML::Node item : recs->second) {
YAML::const_iterator rec = item.begin();
for(YAML::const_iterator item = recs->second.begin(); item != recs->second.end(); item++) {
YAML::const_iterator rec = item->begin();
GeoIPDNSResourceRecord rr;
rr.domain_id = dom.id;
rr.ttl = dom.ttl;
Expand Down

0 comments on commit 1a2d029

Please sign in to comment.