From 837f1f62a8c4efdf1213c8eb503ddc3d37ce3115 Mon Sep 17 00:00:00 2001 From: cflakes Date: Sat, 1 May 2010 18:47:52 +0000 Subject: [PATCH] Refuse harder and print a debug warning in case some bad code tries to write invalid lines to the config file. Patch by DGandalf, thanks. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1962 726aef4b-f618-498e-8847-2d620e286838 --- User.cpp | 7 ++++++- User.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/User.cpp b/User.cpp index e58a058e..44c38151 100644 --- a/User.cpp +++ b/User.cpp @@ -602,8 +602,13 @@ bool CUser::DelChan(const CString& sName) { return false; } -bool CUser::PrintLine(CFile& File, const CString& sName, const CString& sValue) { +bool CUser::PrintLine(CFile& File, CString sName, CString sValue) { + sName.Trim(); + sValue.Trim(); + if (sName.empty() || sValue.empty()) { + DEBUG("Refused writing an invalid line to a user config. [" + << sName << "] [" << sValue << "]"); return false; } diff --git a/User.h b/User.h index 39750e9c..088235c3 100644 --- a/User.h +++ b/User.h @@ -46,7 +46,7 @@ public: return CUtils::SaltedSHA256Hash(sPass, sSalt); } - bool PrintLine(CFile& File, const CString& sName, const CString& sValue); + bool PrintLine(CFile& File, CString sName, CString sValue); bool WriteConfig(CFile& File); CChan* FindChan(const CString& sName) const; bool AddChan(CChan* pChan);