From ef5e8b6920d1dd3097f36bd0c50170100acf2f28 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Tue, 3 Jun 2014 11:02:58 +0200 Subject: [PATCH] Fix base64 decoding of Ed25519 keys. --- src/invitation.c | 2 +- src/utils.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/invitation.c b/src/invitation.c index 7fb96dac..a6996cc6 100644 --- a/src/invitation.c +++ b/src/invitation.c @@ -906,7 +906,7 @@ int cmd_join(int argc, char *argv[]) { if(!port || !*port) port = "655"; - if(!b64decode(slash, hash, 18) || !b64decode(slash + 24, cookie, 18)) + if(!b64decode(slash, hash, 24) || !b64decode(slash + 24, cookie, 24)) goto invalid; // Generate a throw-away key for the invitation. diff --git a/src/utils.c b/src/utils.c index 594c91a5..0d7bc02f 100644 --- a/src/utils.c +++ b/src/utils.c @@ -75,7 +75,7 @@ int b64decode(const char *src, void *dst, int length) { uint32_t triplet = 0; unsigned char *udst = (unsigned char *)dst; - for(i = 0; i < length / 3 * 4 && src[i]; i++) { + for(i = 0; i < length && src[i]; i++) { triplet |= base64_decode[src[i] & 0xff] << (6 * (i & 3)); if((i & 3) == 3) { if(triplet & 0xff000000U) -- 2.20.1