From ae65df048d7359951fa2ddabc7ae52c7270641e6 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Thu, 5 Mar 2020 16:13:09 -0500 Subject: [PATCH] Fix UBsan finding (GH #71) Also see https://github.com/NLnetLabs/unbound/commit/57bbbfc0e6d9, where Unbound clared a similar finding with uint32_t casts. --- util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util.c b/util.c index 1216134f..fb129e12 100644 --- a/util.c +++ b/util.c @@ -295,11 +295,11 @@ ldns_gmtime64_r(int64_t clock, struct tm *result) static int64_t ldns_serial_arithmitics_time(int32_t time, time_t now) { - int32_t offset = time - (int32_t) now; + /* Casting due to https://github.com/NLnetLabs/ldns/issues/71 */ + int32_t offset = (int32_t) ((uint32_t) time - (uint32_t) now); return (int64_t) now + offset; } - struct tm * ldns_serial_arithmitics_gmtime_r(int32_t time, time_t now, struct tm *result) { -- 2.47.3