{
checkReadOffset(m_read_offset, 2);
u16 strLen = readU16(&m_data[m_read_offset]);
- m_read_offset += sizeof(u16);
+ m_read_offset += 2;
dst.clear();
NetworkPacket& NetworkPacket::operator<<(std::string src)
{
u16 msgsize = src.size();
- if (msgsize > 0xFFFF) {
- msgsize = 0xFFFF;
+ if (msgsize > STRING_MAX_LEN) {
+ throw PacketError("String too long");
}
*this << msgsize;
void NetworkPacket::putLongString(std::string src)
{
u32 msgsize = src.size();
- if (msgsize > 0xFFFFFFFF) {
- msgsize = 0xFFFFFFFF;
+ if (msgsize > LONG_STRING_MAX_LEN) {
+ throw PacketError("String too long");
}
*this << msgsize;
NetworkPacket& NetworkPacket::operator<<(std::wstring src)
{
u16 msgsize = src.size();
- if (msgsize > 0xFFFF) {
- msgsize = 0xFFFF;
+ if (msgsize > WIDE_STRING_MAX_LEN) {
+ throw PacketError("String too long");
}
*this << msgsize;
return "";
}
+ if (strLen > LONG_STRING_MAX_LEN) {
+ throw PacketError("String too long");
+ }
+
checkReadOffset(m_read_offset, strLen);
std::string dst;