From de5cc82b5b29a47b0cc7de08800fe38860228850 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Mon, 16 Sep 2013 19:25:31 +0000 Subject: [PATCH] Build fix to eliminate strict aliasing warnings, and a bug fix. --- node/C25519.cpp | 10 +++++++++- node/Utils.hpp | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/node/C25519.cpp b/node/C25519.cpp index eab7d110f..7b933e23a 100644 --- a/node/C25519.cpp +++ b/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); } diff --git a/node/Utils.hpp b/node/Utils.hpp index b214c78c9..991ae31b0 100644 --- a/node/Utils.hpp +++ b/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; } }