| 170 | |
| 171 | |
| 172 | void cRCONServer::cConnection::DataReceived(const char * a_Data, size_t a_Size) |
| 173 | { |
| 174 | // Append data to the buffer: |
| 175 | m_Buffer.append(a_Data, a_Size); |
| 176 | |
| 177 | // Process the packets in the buffer: |
| 178 | while (m_Buffer.size() >= 14) |
| 179 | { |
| 180 | int Length = IntFromBuffer(m_Buffer.data()); |
| 181 | if (Length > 1500) |
| 182 | { |
| 183 | // Too long, drop the connection |
| 184 | LOGWARNING("Received an invalid RCON packet length (%d), dropping RCON connection to %s.", |
| 185 | Length, m_IPAddress.c_str() |
| 186 | ); |
| 187 | m_RCONServer.m_SocketThreads.RemoveClient(this); |
| 188 | m_Socket.CloseSocket(); |
| 189 | delete this; |
| 190 | return; |
| 191 | } |
| 192 | if (Length > (int)(m_Buffer.size() + 4)) |
| 193 | { |
| 194 | // Incomplete packet yet, wait for more data to come |
| 195 | return; |
| 196 | } |
| 197 | |
| 198 | int RequestID = IntFromBuffer(m_Buffer.data() + 4); |
| 199 | int PacketType = IntFromBuffer(m_Buffer.data() + 8); |
| 200 | if (!ProcessPacket(RequestID, PacketType, Length - 10, m_Buffer.data() + 12)) |
| 201 | { |
| 202 | m_RCONServer.m_SocketThreads.RemoveClient(this); |
| 203 | m_Socket.CloseSocket(); |
| 204 | delete this; |
| 205 | return; |
| 206 | } |
| 207 | m_Buffer.erase(0, Length + 4); |
| 208 | } // while (m_Buffer.size() >= 14) |
| 209 | } |
| 210 | |
| 211 | |
| 212 |
nothing calls this directly
no test coverage detected