X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fhelperfuncs.cpp;h=439320c1e00d85334c29d3da845357b246d11cfa;hb=74a95f4e1312ef5a628da484b6cb39c417e2fceb;hp=3795e63987cbb5c4b46708e9b665989c00502bda;hpb=790f8c35841ef7c9ec123242611613b540f14c2c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 3795e6398..439320c1e 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -140,7 +140,7 @@ Channel* InspIRCd::FindChan(const std::string &chan) /* Send an error notice to all users, registered or not */ void InspIRCd::SendError(const std::string &s) { - for (std::vector::const_iterator i = this->Users->local_users.begin(); i != this->Users->local_users.end(); i++) + for (LocalUserList::const_iterator i = this->Users->local_users.begin(); i != this->Users->local_users.end(); i++) { User* u = *i; if (u->registered == REG_ALL) @@ -339,8 +339,8 @@ bool IsNickHandler::Call(const char* n, size_t max) return false; } - /* too long? or not -- pointer arithmetic rocks */ - return (p < max); + /* too long? or not */ + return (p <= max); } /* return true for good ident, false else */ @@ -495,7 +495,26 @@ bool InspIRCd::SilentULine(const std::string& sserver) std::string InspIRCd::TimeString(time_t curtime) { - return std::string(ctime(&curtime),24); +#ifdef _WIN32 + if (curtime < 0) + curtime = 0; +#endif + + struct tm* timeinfo = localtime(&curtime); + if (!timeinfo) + { + curtime = 0; + timeinfo = localtime(&curtime); + } + + // If the calculated year exceeds four digits or is less than the year 1000, + // the behavior of asctime() is undefined + if (timeinfo->tm_year + 1900 > 9999) + timeinfo->tm_year = 9999 - 1900; + else if (timeinfo->tm_year + 1900 < 1000) + timeinfo->tm_year = 0; + + return std::string(asctime(timeinfo),24); } // You should only pass a single character to this.