summaryrefslogtreecommitdiff
path: root/node/Node.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2017-07-13 15:08:57 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2017-07-13 15:08:57 -0700
commitba6fd168235fac1c2ec029a49616510da56efe0f (patch)
treeb56e28a577c947495621ac6a93ec0b8cd99ea0b6 /node/Node.cpp
parent54893c35c113b2a1f2fab2fcbefed258c755c75e (diff)
downloadinfinitytier-ba6fd168235fac1c2ec029a49616510da56efe0f.tar.gz
infinitytier-ba6fd168235fac1c2ec029a49616510da56efe0f.zip
More tracing stuff.
Diffstat (limited to 'node/Node.cpp')
-rw-r--r--node/Node.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/node/Node.cpp b/node/Node.cpp
index 073af4bd..ff3acfc2 100644
--- a/node/Node.cpp
+++ b/node/Node.cpp
@@ -78,7 +78,7 @@ Node::Node(void *uptr,void *tptr,const struct ZT_Node_Callbacks *callbacks,uint6
uint64_t idtmp[2];
idtmp[0] = 0; idtmp[1] = 0;
- char tmp[1024];
+ char tmp[2048];
int n = stateObjectGet(tptr,ZT_STATE_OBJECT_IDENTITY_SECRET,idtmp,tmp,sizeof(tmp) - 1);
if (n > 0) {
tmp[n] = (char)0;
@@ -92,21 +92,18 @@ Node::Node(void *uptr,void *tptr,const struct ZT_Node_Callbacks *callbacks,uint6
if (n <= 0) {
RR->identity.generate();
- idtmp[0] = RR->identity.address().toInt(); idtmp[1] = 0;
RR->identity.toString(false,RR->publicIdentityStr);
RR->identity.toString(true,RR->secretIdentityStr);
+ idtmp[0] = RR->identity.address().toInt(); idtmp[1] = 0;
stateObjectPut(tptr,ZT_STATE_OBJECT_IDENTITY_SECRET,idtmp,RR->secretIdentityStr,(unsigned int)strlen(RR->secretIdentityStr));
stateObjectPut(tptr,ZT_STATE_OBJECT_IDENTITY_PUBLIC,idtmp,RR->publicIdentityStr,(unsigned int)strlen(RR->publicIdentityStr));
} else {
idtmp[0] = RR->identity.address().toInt(); idtmp[1] = 0;
n = stateObjectGet(tptr,ZT_STATE_OBJECT_IDENTITY_PUBLIC,idtmp,tmp,sizeof(tmp) - 1);
- if (n > 0) {
- tmp[n] = (char)0;
- if (RR->publicIdentityStr != tmp)
- n = -1;
+ if ((n > 0)&&(n < sizeof(RR->publicIdentityStr))&&(n < sizeof(tmp))) {
+ if (memcmp(tmp,RR->publicIdentityStr,n))
+ stateObjectPut(tptr,ZT_STATE_OBJECT_IDENTITY_PUBLIC,idtmp,RR->publicIdentityStr,(unsigned int)strlen(RR->publicIdentityStr));
}
- if (n <= 0)
- stateObjectPut(tptr,ZT_STATE_OBJECT_IDENTITY_PUBLIC,idtmp,RR->publicIdentityStr,(unsigned int)strlen(RR->publicIdentityStr));
}
try {