diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-01-18 20:03:24 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-01-18 20:03:24 +0000 |
commit | ece2c5daca87ca8b6759857a27de342e2df98b21 (patch) | |
tree | 46ec68f5515abd062a177d9425e706ca2688f80d | |
parent | 93824184400d603aaeda09f9b4cd59c4f85ce3a9 (diff) |
strncpy sucks ass! -- Old code was using strncpy which doesnt null terminate a string if the string fills a buffer (!!!) - our strlcpy implementation fixes this.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2817 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | src/channels.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index 552da3a5d..fa8c56188 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -94,7 +94,7 @@ void chanrec::SetCustomMode(char mode,bool mode_on) std::string a = this->custom_modes; int pos = a.find(mode); a.erase(pos,1); - strncpy(this->custom_modes,a.c_str(),MAXMODES); + strlcpy(this->custom_modes,a.c_str(),MAXMODES); log(DEBUG,"Custom mode %c removed: modelist='%s'",mode,this->custom_modes); this->SetCustomModeParam(mode,"",false); @@ -195,7 +195,8 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri int created = 0; char cname[MAXBUF]; int MOD_RESULT = 0; - strncpy(cname,cn,CHANMAX); + strlcpy(cname,cn,CHANMAX); + log(DEBUG,"cname='%s' cn='%s'",cname,cn); log(DEBUG,"add_channel: %s %s",user->nick,cname); @@ -216,7 +217,7 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri chanlist[cname]->binarymodes = CM_TOPICLOCK | CM_NOEXTERNAL; chanlist[cname]->created = TIME; *chanlist[cname]->topic = 0; - strncpy(chanlist[cname]->setby, user->nick,NICKMAX); + strlcpy(chanlist[cname]->setby, user->nick,NICKMAX); chanlist[cname]->topicset = 0; Ptr = chanlist[cname]; log(DEBUG,"add_channel: created: %s",cname); |