diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-06-24 14:43:36 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-06-24 14:43:36 +0000 |
commit | 7b0fcbfc069b201a8c295c956bcf2287abd26894 (patch) | |
tree | 238592a6e30d425af49b24902b7cf78e7e320513 /src/helperfuncs.cpp | |
parent | 72e17538de4413021804daf3d3b9aa6991adde0d (diff) |
Forwardport of safety fixes for Write* functions
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4056 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/helperfuncs.cpp')
-rw-r--r-- | src/helperfuncs.cpp | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index b2c8c1b3b..d0009328c 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -155,11 +155,11 @@ void Write_NoFormat(int sock, const char *text) if ((sock < 0) || (!text) || (sock > MAX_DESCRIPTORS)) return; - bytes = snprintf(tb,MAXBUF,"%s\r\n",text); - chop(tb); - if (fd_ref_table[sock]) { + bytes = snprintf(tb,MAXBUF,"%s\r\n",text); + chop(tb); + if (Config->GetIOHook(fd_ref_table[sock]->port)) { try @@ -200,14 +200,15 @@ void Write(int sock, char *text, ...) return; } - va_start(argsPtr, text); - vsnprintf(textbuffer, MAXBUF, text, argsPtr); - va_end(argsPtr); - bytes = snprintf(tb,MAXBUF,"%s\r\n",textbuffer); - chop(tb); - if (fd_ref_table[sock]) { + + va_start(argsPtr, text); + vsnprintf(textbuffer, MAXBUF, text, argsPtr); + va_end(argsPtr); + bytes = snprintf(tb,MAXBUF,"%s\r\n",textbuffer); + chop(tb); + if (Config->GetIOHook(fd_ref_table[sock]->port)) { try @@ -240,11 +241,11 @@ void WriteServ_NoFormat(int sock, const char* text) if ((sock < 0) || (!text) || (sock > MAX_DESCRIPTORS)) return; - bytes = snprintf(tb,MAXBUF,":%s %s\r\n",Config->ServerName,text); - chop(tb); - if (fd_ref_table[sock]) { + bytes = snprintf(tb,MAXBUF,":%s %s\r\n",Config->ServerName,text); + chop(tb); + if (Config->GetIOHook(fd_ref_table[sock]->port)) { try @@ -283,6 +284,9 @@ void WriteServ(int sock, char* text, ...) return; } + if (!fd_ref_table[sock]) + return; + va_start(argsPtr, text); vsnprintf(textbuffer, MAXBUF, text, argsPtr); va_end(argsPtr); @@ -302,11 +306,11 @@ void WriteFrom_NoFormat(int sock, userrec *user, const char* text) if ((sock < 0) || (!text) || (!user) || (sock > MAX_DESCRIPTORS)) return; - bytes = snprintf(tb,MAXBUF,":%s %s\r\n",user->GetFullHost(),text); - chop(tb); - if (fd_ref_table[sock]) { + bytes = snprintf(tb,MAXBUF,":%s %s\r\n",user->GetFullHost(),text); + chop(tb); + if (Config->GetIOHook(fd_ref_table[sock]->port)) { try @@ -346,14 +350,15 @@ void WriteFrom(int sock, userrec *user,char* text, ...) return; } - va_start(argsPtr, text); - vsnprintf(textbuffer, MAXBUF, text, argsPtr); - va_end(argsPtr); - bytes = snprintf(tb,MAXBUF,":%s %s\r\n",user->GetFullHost(),textbuffer); - chop(tb); - if (fd_ref_table[sock]) { + + va_start(argsPtr, text); + vsnprintf(textbuffer, MAXBUF, text, argsPtr); + va_end(argsPtr); + bytes = snprintf(tb,MAXBUF,":%s %s\r\n",user->GetFullHost(),textbuffer); + chop(tb); + if (Config->GetIOHook(fd_ref_table[sock]->port)) { try |