From c11511b94b316fcbef0ba17c50ef600d6c8f5d0e Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Mon, 26 Sep 2016 14:52:10 +0200 Subject: [PATCH] Revert "Merge pull request #947 from mind04/right" This code only served to fix a combination of system misconfiguration and a bug in glibc. Meanwhile it turns out this code is incorrect. Removing it. (cherry picked from commit c96765dae8da4c9322ca4a80e3e101d64faf141f) --- pdns/rcpgenerator.cc | 2 +- pdns/unix_utility.cc | 27 --------------------------- pdns/utility.hh | 3 +-- 3 files changed, 2 insertions(+), 30 deletions(-) diff --git a/pdns/rcpgenerator.cc b/pdns/rcpgenerator.cc index 28edc95f4..5df380622 100644 --- a/pdns/rcpgenerator.cc +++ b/pdns/rcpgenerator.cc @@ -495,7 +495,7 @@ void RecordTextWriter::xfrTime(const uint32_t& val) struct tm tm; time_t time=val; // Y2038 bug! - Utility::gmtime_r(&time, &tm); + gmtime_r(&time, &tm); char tmp[16]; snprintf(tmp,sizeof(tmp)-1, "%04d%02d%02d" "%02d%02d%02d", diff --git a/pdns/unix_utility.cc b/pdns/unix_utility.cc index ed58314d0..9fbe2c860 100644 --- a/pdns/unix_utility.cc +++ b/pdns/unix_utility.cc @@ -305,30 +305,3 @@ time_t Utility::timegm(struct tm *const t) return ((day + t->tm_hour) * i + t->tm_min) * i + t->tm_sec; } -// we have our own gmtime_r because the one in GNU libc violates POSIX/SuS -// by supporting leap seconds when TZ=right/UTC -void Utility::gmtime_r(const time_t *timer, struct tm *tmbuf) { - - int monthdays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; - int days = *timer / 86400; - int leapdays = (days + 671) / 1461; - int leapydays = (days + 365) / 1461; - - tmbuf->tm_hour = *timer / 3600 % 24; - tmbuf->tm_min = *timer / 60 % 60; - tmbuf->tm_sec = *timer % 60; - - tmbuf->tm_year = (days - leapdays) / 365 + 70; - tmbuf->tm_yday = days - leapydays - (tmbuf->tm_year - 70) * 365 + 1; - - tmbuf->tm_mon = 0; - tmbuf->tm_mday = tmbuf->tm_yday; - monthdays[1] += isleap(tmbuf->tm_year + 1900); - while (monthdays[tmbuf->tm_mon] < tmbuf->tm_mday) { - tmbuf->tm_mday -= monthdays[tmbuf->tm_mon]; - tmbuf->tm_mon++; - } - - tmbuf->tm_wday = (days + 4) % 7; // Day 0 is magic thursday ;) - tmbuf->tm_isdst = 0; -} diff --git a/pdns/utility.hh b/pdns/utility.hh index 0f344a27a..8ea95fadc 100644 --- a/pdns/utility.hh +++ b/pdns/utility.hh @@ -151,8 +151,7 @@ public: static void usleep( unsigned long usec ); static time_t timegm(struct tm *tm); - - static void gmtime_r(const time_t *timer, struct tm *tmbuf); + }; -- 2.40.0