From 49662179e9d41f96ec518376a99777773562d7c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Fri, 27 Jan 2017 19:23:26 +0000 Subject: [PATCH] Refuse to create a new mud with a bad clock --- mud.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mud.c b/mud.c index 12a6d2c..3d01f36 100644 --- a/mud.c +++ b/mud.c @@ -249,7 +249,7 @@ mud_now(void) gettimeofday(&tv, NULL); now = (tv.tv_sec - MUD_EPOCH) * MUD_ONE_SEC + tv.tv_usec; #endif - return now & ((UINT64_C(1) << 48) - 1); + return now; } static uint64_t @@ -721,6 +721,11 @@ mud_keyx_init(struct mud *mud, uint64_t now) struct mud * mud_create(int port, int v4, int v6, int aes, int mtu) { + uint64_t now = mud_now(); + + if (now >> 48) + return NULL; + if (sodium_init() == -1) return NULL;