From 990c96c992c4cf21173c904dd85f0b378e1c89b0 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 19 Oct 2011 01:05:22 +0300 Subject: Hide passwords from packets logs. --- src/net/messageout.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/net/messageout.cpp') diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp index a8b66f5ae..f18f65a93 100644 --- a/src/net/messageout.cpp +++ b/src/net/messageout.cpp @@ -82,6 +82,34 @@ void MessageOut::writeString(const std::string &string, int length) PacketCounters::incOutBytes(length); } +void MessageOut::writeStringNoLog(const std::string &string, int length) +{ + DEBUGLOG("writeString: ***"); + int stringLength = static_cast(string.length()); + if (length < 0) + { + // Write the length at the start if not fixed + writeInt16(static_cast(stringLength)); + length = stringLength; + } + else if (length < stringLength) + { + // Make sure the length of the string is no longer than specified + stringLength = length; + } + expand(length); + + // Write the actual string + memcpy(mData + mPos, string.c_str(), stringLength); + + // Pad remaining space with zeros + if (length > stringLength) + memset(mData + mPos + stringLength, '\0', length - stringLength); + + mPos += length; + PacketCounters::incOutBytes(length); +} + char *MessageOut::getData() const { return mData; -- cgit v1.2.3-60-g2f50