diff --git a/znc.cpp b/znc.cpp index bb5a5d61..b9095cdf 100644 --- a/znc.cpp +++ b/znc.cpp @@ -71,14 +71,25 @@ CZNC::~CZNC() { DeletePidFile(); } +CString CZNC::GetVersion() { + char szBuf[128]; + + snprintf(szBuf, sizeof(szBuf), "%1.3f"VERSION_EXTRA, VERSION); + // If snprintf overflows (which I doubt), we want to be on the safe side + szBuf[sizeof(szBuf) - 1] = '\0'; + + return szBuf; +} + CString CZNC::GetTag(bool bIncludeVersion) { if (!bIncludeVersion) { return "ZNC - http://znc.sourceforge.net"; } char szBuf[128]; - memset(szBuf, 0, 128); - snprintf(szBuf, 127, "ZNC %1.3f"VERSION_EXTRA" - http://znc.sourceforge.net", VERSION); + snprintf(szBuf, sizeof(szBuf), "ZNC %1.3f"VERSION_EXTRA" - http://znc.sourceforge.net", VERSION); + // If snprintf overflows (which I doubt), we want to be on the safe side + szBuf[sizeof(szBuf) - 1] = '\0'; return szBuf; } diff --git a/znc.h b/znc.h index 64602ee7..647c60aa 100644 --- a/znc.h +++ b/znc.h @@ -108,6 +108,7 @@ public: bool WriteConfig(); bool ParseConfig(const CString& sConfig); bool RehashConfig(CString& sError); + static CString GetVersion(); static CString GetTag(bool bIncludeVersion = true); // This returns the path to the .so and to the data dir // which is where static data (webadmin skins) are saved