diff options
-rw-r--r-- | src/coremods/core_channel/cmd_names.cpp | 2 | ||||
-rw-r--r-- | src/inspsocket.cpp | 2 | ||||
-rw-r--r-- | src/users.cpp | 17 |
3 files changed, 12 insertions, 9 deletions
diff --git a/src/coremods/core_channel/cmd_names.cpp b/src/coremods/core_channel/cmd_names.cpp index dd2926c33..92f0810de 100644 --- a/src/coremods/core_channel/cmd_names.cpp +++ b/src/coremods/core_channel/cmd_names.cpp @@ -36,7 +36,7 @@ CmdResult CommandNames::HandleLocal(const std::vector<std::string>& parameters, { Channel* c; - if (!parameters.size()) + if (parameters.empty()) { user->WriteNumeric(RPL_ENDOFNAMES, '*', "End of /NAMES list."); return CMD_SUCCESS; diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index 709ad443b..42e2640a6 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -293,7 +293,7 @@ void StreamSocket::FlushSendQ(SendQueue& sq) const SendQueue::Element& elem = *i; iovecs[j].iov_base = const_cast<char*>(elem.data()); iovecs[j].iov_len = elem.length(); - rv_max += elem.length(); + rv_max += iovecs[j].iov_len; } rv = SocketEngine::WriteV(this, iovecs, bufcount); } diff --git a/src/users.cpp b/src/users.cpp index 7f56994d4..5f31ff299 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -645,8 +645,8 @@ bool User::ChangeNick(const std::string& newnick, time_t newts) } if (this->registered == REG_ALL) - this->WriteCommon("NICK %s",newnick.c_str()); - std::string oldnick = nick; + this->WriteCommon("NICK %s", newnick.c_str()); + const std::string oldnick = nick; nick = newnick; InvalidateCache(); @@ -767,10 +767,12 @@ void LocalUser::Write(const std::string& text) if (!SocketEngine::BoundsCheckFd(&eh)) return; - if (text.length() > ServerInstance->Config->Limits.MaxLine - 2) + // The maximum size of an IRC message minus the terminating CR+LF. + const size_t maxmessage = ServerInstance->Config->Limits.MaxLine - 2; + if (text.length() > maxmessage) { - // this should happen rarely or never. Crop the string at 512 and try again. - std::string try_again(text, 0, ServerInstance->Config->Limits.MaxLine - 2); + // This should happen rarely or never. Crop the string at MaxLine and try again. + std::string try_again(text, 0, maxmessage); Write(try_again); return; } @@ -780,8 +782,9 @@ void LocalUser::Write(const std::string& text) eh.AddWriteBuf(text); eh.AddWriteBuf(wide_newline); - ServerInstance->stats.Sent += text.length() + 2; - this->bytes_out += text.length() + 2; + const size_t bytessent = text.length() + 2; + ServerInstance->stats.Sent += bytessent; + this->bytes_out += bytessent; this->cmds_out++; } |