Browse Source

Build fix to eliminate strict aliasing warnings, and a bug fix.

Adam Ierymenko 12 years ago
parent
commit
de5cc82b5b
2 changed files with 10 additions and 2 deletions
  1. 9 1
      node/C25519.cpp
  2. 1 1
      node/Utils.hpp

+ 9 - 1
node/C25519.cpp

@@ -33,6 +33,7 @@
 #include "C25519.hpp"
 #include "Utils.hpp"
 #include "SHA512.hpp"
+#include "Buffer.hpp"
 
 namespace ZeroTier {
 
@@ -1895,9 +1896,16 @@ static void p1p1_to_p2(ge25519_p2 *r, const ge25519_p1p1 *p)
   fe25519_mul(&r->z, &p->z, &p->t);
 }
 
+static void p1p1_to_p2_2(ge25519_p3 *r, const ge25519_p1p1 *p)
+{
+  fe25519_mul(&r->x, &p->x, &p->t);
+  fe25519_mul(&r->y, &p->y, &p->z);
+  fe25519_mul(&r->z, &p->z, &p->t);
+}
+
 static void p1p1_to_p3(ge25519_p3 *r, const ge25519_p1p1 *p)
 {
-  p1p1_to_p2((ge25519_p2 *)r, p);
+  p1p1_to_p2_2(r, p);
   fe25519_mul(&r->t, &p->x, &p->y);
 }
 

+ 1 - 1
node/Utils.hpp

@@ -572,7 +572,7 @@ public:
 		char *end = dest + len;
 		while ((*dest++ = *src++)) {
 			if (dest == end) {
-				dest[len - 1] = (char)0;
+				--dest = (char)0;
 				return false;
 			}
 		}