]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Whoops, ++it++? Thats gonna break :p
[user/henk/code/inspircd.git] / src / users.cpp
index e79d27c8b74cfc70290235b97c4fd70bd538a2ec..906a2e9c3dccda8936052850b3ccae66d11cc3ba 100644 (file)
  * ---------------------------------------------------
  */
 
+#include "inspircd.h"
 #include "configreader.h"
 #include "channels.h"
 #include "users.h"
-#include "inspircd.h"
 #include <stdarg.h>
 #include "socketengine.h"
 #include "wildcard.h"
@@ -476,7 +476,7 @@ int userrec::ReadData(void* buffer, size_t size)
 #ifndef WIN32
                return read(this->fd, buffer, size);
 #else
-        return recv(this->fd, (char*)buffer, size, 0);
+               return recv(this->fd, (char*)buffer, size, 0);
 #endif
        }
        else
@@ -650,8 +650,12 @@ std::string userrec::GetBuffer()
                 * Usually there are only one or two of these,
                 * so its is computationally cheap to do.
                 */
-               while ((*recvq.begin() == '\r') || (*recvq.begin() == '\n'))
-                       recvq.erase(recvq.begin());
+               std::string::iterator t = recvq.begin();
+               while (t != recvq.end() && (*t == '\r' || *t == '\n'))
+               {
+                       recvq.erase(t);
+                       t = recvq.begin();
+               }
 
                for (std::string::iterator x = recvq.begin(); x != recvq.end(); x++)
                {
@@ -719,9 +723,9 @@ void userrec::FlushWriteBuf()
                {
                        int old_sendq_length = sendq.length();
 #ifndef WIN32
-            int n_sent = write(this->fd, this->sendq.data(), this->sendq.length());
+               int n_sent = write(this->fd, this->sendq.data(), this->sendq.length());
 #else
-            int n_sent = send(this->fd, (const char*)this->sendq.data(), this->sendq.length(), 0);
+               int n_sent = send(this->fd, (const char*)this->sendq.data(), this->sendq.length(), 0);
 #endif
                        if (n_sent == -1)
                        {
@@ -913,6 +917,13 @@ void userrec::AddClient(InspIRCd* Instance, int socket, int port, bool iscached,
         * See my note down there for why this is required. DO NOT REMOVE. :) -- w00t
         */
        ConnectClass* i = New->GetClass();
+
+       if (!i)
+       {
+               userrec::QuitUser(Instance, New, "Access denied by configuration");
+               return;
+       }
+
        New->CheckClass();
 
        New->pingmax = i->GetPingTime();