summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2017-01-11 17:59:51 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2017-01-11 17:59:51 -0800
commit56d969c709fe938a2a2975b4b3fb485f181495ae (patch)
treebccb3302a1fc9e1669eff7c44f5844806ed37ecf
parent3fedf16f353f2b4ce37f279cb44f254bf7ef3c5b (diff)
downloadinfinitytier-56d969c709fe938a2a2975b4b3fb485f181495ae.tar.gz
infinitytier-56d969c709fe938a2a2975b4b3fb485f181495ae.zip
.
-rw-r--r--service/SoftwareUpdater.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/service/SoftwareUpdater.cpp b/service/SoftwareUpdater.cpp
index 56315f48..1ed924ca 100644
--- a/service/SoftwareUpdater.cpp
+++ b/service/SoftwareUpdater.cpp
@@ -376,16 +376,14 @@ void SoftwareUpdater::handleSoftwareUpdateUserMessage(uint64_t origin,const void
idx |= (unsigned long)*(reinterpret_cast<const uint8_t *>(data) + 20);
printf("<< GET_DATA @%u from %.10llx for %s\n",(unsigned int)idx,origin,Utils::hex(reinterpret_cast<const uint8_t *>(data) + 1,16).c_str());
std::map< Array<uint8_t,16>,_D >::iterator d(_dist.find(Array<uint8_t,16>(reinterpret_cast<const uint8_t *>(data) + 1)));
- if (d != _dist.end()) {
- if (idx < d->second.bin.length()) {
- Buffer<ZT_SOFTWARE_UPDATE_CHUNK_SIZE + 128> buf;
- buf.append((uint8_t)VERB_DATA);
- buf.append(reinterpret_cast<const uint8_t *>(data) + 1,16);
- buf.append((uint32_t)idx);
- buf.append(d->second.bin.data() + idx,std::max((unsigned long)ZT_SOFTWARE_UPDATE_CHUNK_SIZE,(unsigned long)(d->second.bin.length() - idx)));
- _node.sendUserMessage(origin,ZT_SOFTWARE_UPDATE_USER_MESSAGE_TYPE,buf.data(),buf.size());
- printf(">> DATA @%u\n",(unsigned int)idx);
- }
+ if ((d != _dist.end())&&(idx < d->second.bin.length())) {
+ Buffer<ZT_SOFTWARE_UPDATE_CHUNK_SIZE + 128> buf;
+ buf.append((uint8_t)VERB_DATA);
+ buf.append(reinterpret_cast<const uint8_t *>(data) + 1,16);
+ buf.append((uint32_t)idx);
+ buf.append(d->second.bin.data() + idx,std::min((unsigned long)ZT_SOFTWARE_UPDATE_CHUNK_SIZE,(unsigned long)(d->second.bin.length() - idx)));
+ _node.sendUserMessage(origin,ZT_SOFTWARE_UPDATE_USER_MESSAGE_TYPE,buf.data(),buf.size());
+ printf(">> DATA @%u\n",(unsigned int)idx);
}
}
break;