From: Martin Basti Date: Thu, 9 Jul 2026 12:25:33 +0000 (+0200) Subject: Make isc_time_nowplusinterval consistent with other functions X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=995308e416c3ec99cba4c69e12f46fc2b8ee3faf;p=thirdparty%2Fbind9.git Make isc_time_nowplusinterval consistent with other functions isc_time_nowplusinterval was using different code than the rest of functions in the time.c. Replace custom overflow logic with ckd_add macro. --- diff --git a/lib/isc/time.c b/lib/isc/time.c index 9806298e676..58681988b1a 100644 --- a/lib/isc/time.c +++ b/lib/isc/time.c @@ -148,19 +148,19 @@ isc_time_nowplusinterval(isc_time_t *t, const isc_interval_t *i) { return ISC_R_UNEXPECTED; } - /* - * Ensure the resulting seconds value fits in the size of an - * unsigned int. - */ - if ((unsigned int)ts.tv_sec > UINT_MAX - i->seconds) { + /* Seconds */ + if (ckd_add(&t->seconds, ts.tv_sec, i->seconds)) { return ISC_R_RANGE; } - t->seconds = ts.tv_sec + i->seconds; + /* Nanoseconds */ t->nanoseconds = ts.tv_nsec + i->nanoseconds; if (t->nanoseconds >= NS_PER_SEC) { - t->seconds++; + if (t->seconds == UINT_MAX) { + return ISC_R_RANGE; + } t->nanoseconds -= NS_PER_SEC; + t->seconds++; } return ISC_R_SUCCESS;