diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2019-06-17 14:38:27 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2019-06-17 14:38:27 -0700 |
commit | 2dc783214c25cdba80b2188e91a973cc8968aee4 (patch) | |
tree | f1eed82d97072e7bc3520681037d295614927c3a /node | |
parent | 523df47a654efffd22168384d9c8b2e8b26aafb0 (diff) | |
download | infinitytier-2dc783214c25cdba80b2188e91a973cc8968aee4.tar.gz infinitytier-2dc783214c25cdba80b2188e91a973cc8968aee4.zip |
Allocate outp on heap in Peer.
Diffstat (limited to 'node')
-rw-r--r-- | node/Peer.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/node/Peer.cpp b/node/Peer.cpp index a053ee48..cbd07799 100644 --- a/node/Peer.cpp +++ b/node/Peer.cpp @@ -212,10 +212,10 @@ void Peer::received( if (pathsToPush.size() > 0) { std::vector<InetAddress>::const_iterator p(pathsToPush.begin()); while (p != pathsToPush.end()) { - Packet outp(_id.address(),RR->identity.address(),Packet::VERB_PUSH_DIRECT_PATHS); - outp.addSize(2); // leave room for count + Packet *outp = new Packet(_id.address(),RR->identity.address(),Packet::VERB_PUSH_DIRECT_PATHS); + outp->addSize(2); // leave room for count unsigned int count = 0; - while ((p != pathsToPush.end())&&((outp.size() + 24) < 1200)) { + while ((p != pathsToPush.end())&&((outp->size() + 24) < 1200)) { uint8_t addressType = 4; switch(p->ss_family) { case AF_INET: @@ -228,22 +228,23 @@ void Peer::received( continue; } - outp.append((uint8_t)0); // no flags - outp.append((uint16_t)0); // no extensions - outp.append(addressType); - outp.append((uint8_t)((addressType == 4) ? 6 : 18)); - outp.append(p->rawIpData(),((addressType == 4) ? 4 : 16)); - outp.append((uint16_t)p->port()); + outp->append((uint8_t)0); // no flags + outp->append((uint16_t)0); // no extensions + outp->append(addressType); + outp->append((uint8_t)((addressType == 4) ? 6 : 18)); + outp->append(p->rawIpData(),((addressType == 4) ? 4 : 16)); + outp->append((uint16_t)p->port()); ++count; ++p; } if (count) { - outp.setAt(ZT_PACKET_IDX_PAYLOAD,(uint16_t)count); - outp.compress(); - outp.armor(_key,true); - path->send(RR,tPtr,outp.data(),outp.size(),now); + outp->setAt(ZT_PACKET_IDX_PAYLOAD,(uint16_t)count); + outp->compress(); + outp->armor(_key,true); + path->send(RR,tPtr,outp->data(),outp->size(),now); } + delete outp; } } } |