Fix/Patch 7.6 Yurots Crash Fix

Wirless

7.6 is the best :D
Joined
Nov 3, 2012
Messages
1,024
Best answers
1
Reaction score
193
Location
Ireland-Poland
replace NetworkMessage:GetRaw to
std::string NetworkMessage::GetRaw(){
int stringlen = m_MsgSize- m_ReadPos;
if ((stringlen >= (16384 - m_ReadPos)) || stringlen <=0)
return std::string();

char* v = (char*)(m_MsgBuf+m_ReadPos);
m_ReadPos += stringlen;
return std::string(v, stringlen);
}
#else
std::string NetworkMessage::GetRaw(){
int stringlen = m_MsgSize- m_ReadPos;
if (stringlen >= (16384 - m_ReadPos))
return std::string();

char* v = (char*)(m_MsgBuf+m_ReadPos);
m_ReadPos += stringlen;
return std::string(v, stringlen);
}
 

4drik

Advanced OT User
Joined
Jun 30, 2014
Messages
200
Best answers
0
Reaction score
155
Jak juz poprawiac to zabierzmy sie za to konkretnie :)
C++:
std::string NetworkMessage::GetString()
{
    int stringlen = GetU16();
    if(stringlen >= (16384 - m_ReadPos))
        return std::string();

    char* v = (char*)(m_MsgBuf + m_ReadPos);
    m_ReadPos += stringlen;
    return std::string(v, stringlen);
}
Na:
C++:
std::string NetworkMessage::GetString(uint16_t stringlen/* = 0*/)
{
    if(stringlen == 0)
        stringlen = GetU16();

    if((stringlen >= (16384 - m_ReadPos)) || stringlen <= 0)
        return std::string();

    char* v = (char*)(m_MsgBuf + m_ReadPos);
    m_ReadPos += stringlen;
    return std::string(v, stringlen);
}
C++:
std::string    GetString();
Na:
C++:
std::string GetString(uint16_t stringlen = 0);
C++:
std::string NetworkMessage::GetRaw()
{
    int stringlen = m_MsgSize - m_ReadPos;
    if((stringlen >= (16384 - m_ReadPos)) || stringlen <= 0)
        return std::string();

    char* v = (char*)(m_MsgBuf + m_ReadPos);
    m_ReadPos += stringlen;
    return std::string(v, stringlen);
}
Na:
C++:
std::string NetworkMessage::GetRaw()
{
    return GetString(m_MsgSize - m_ReadPos);
}
 
OP
Wirless

Wirless

7.6 is the best :D
Joined
Nov 3, 2012
Messages
1,024
Best answers
1
Reaction score
193
Location
Ireland-Poland
Jak juz poprawiac to zabierzmy sie za to konkretnie :)
C++:
std::string NetworkMessage::GetString()
{
    int stringlen = GetU16();
    if(stringlen >= (16384 - m_ReadPos))
        return std::string();

    char* v = (char*)(m_MsgBuf + m_ReadPos);
    m_ReadPos += stringlen;
    return std::string(v, stringlen);
}
Na:
C++:
std::string NetworkMessage::GetString(uint16_t stringlen/* = 0*/)
{
    if(stringlen == 0)
        stringlen = GetU16();

    if((stringlen >= (16384 - m_ReadPos)) || stringlen <= 0)
        return std::string();

    char* v = (char*)(m_MsgBuf + m_ReadPos);
    m_ReadPos += stringlen;
    return std::string(v, stringlen);
}
C++:
std::string    GetString();
Na:
C++:
std::string GetString(uint16_t stringlen = 0);
C++:
std::string NetworkMessage::GetRaw()
{
    int stringlen = m_MsgSize - m_ReadPos;
    if((stringlen >= (16384 - m_ReadPos)) || stringlen <= 0)
        return std::string();

    char* v = (char*)(m_MsgBuf + m_ReadPos);
    m_ReadPos += stringlen;
    return std::string(v, stringlen);
}
Na:
C++:
std::string NetworkMessage::GetRaw()
{
    return GetString(m_MsgSize - m_ReadPos);
}
twoj jebnie
 

4drik

Advanced OT User
Joined
Jun 30, 2014
Messages
200
Best answers
0
Reaction score
155
W jaki sposob?
 

4drik

Advanced OT User
Joined
Jun 30, 2014
Messages
200
Best answers
0
Reaction score
155
Hello, there's my last edit:
C++:
std::string NetworkMessage::GetString(uint16_t stringlen/* = 0*/, bool getRaw/* = false*/)
{
    if(getRaw == false)
        stringlen = GetU16();

    if((stringlen >= (16384 - m_ReadPos)) || stringlen <= 0)
        return std::string();

    char* v = (char*)(m_MsgBuf + m_ReadPos);
    m_ReadPos += stringlen;
    return std::string(v, stringlen);
}

std::string NetworkMessage::GetRaw()
{
    return GetString(m_MsgSize - m_ReadPos, true);
}
And in networkmessage.h:
C++:
 std::string GetString(uint16_t stringlen = 0, bool getRaw = false);
 

gianflogao

Intermediate OT User
Joined
Jun 6, 2014
Messages
134
Best answers
2
Reaction score
9
Hello, there's my last edit:
C++:
std::string NetworkMessage::GetString(uint16_t stringlen/* = 0*/, bool getRaw/* = false*/)
{
    if(getRaw == false)
        stringlen = GetU16();

    if((stringlen >= (16384 - m_ReadPos)) || stringlen <= 0)
        return std::string();

    char* v = (char*)(m_MsgBuf + m_ReadPos);
    m_ReadPos += stringlen;
    return std::string(v, stringlen);
}

std::string NetworkMessage::GetRaw()
{
    return GetString(m_MsgSize - m_ReadPos, true);
}
And in networkmessage.h:
C++:
 std::string GetString(uint16_t stringlen = 0, bool getRaw = false);

if I do that, won't they be able to break in?

have other invasions in yurOTS 7.6?
 
Top