1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-30 09:59:10 +00:00

(svn r4667) - Backport from trunk (r4291):

Fix: validate all received strings for correctness. This fixes
  potential crashes on hacked clients/servers
This commit is contained in:
Darkvater
2006-05-02 13:00:07 +00:00
parent f8eb72e188
commit aba21dd563
2 changed files with 3 additions and 3 deletions

View File

@@ -273,6 +273,7 @@ uint64 NetworkRecv_uint64(NetworkClientState *cs, Packet *packet)
void NetworkRecv_string(NetworkClientState *cs, Packet *p, char* buffer, size_t size)
{
int pos;
char *bufp = buffer;
/* Don't allow reading from a closed socket */
if (cs->quited)
@@ -289,6 +290,8 @@ void NetworkRecv_string(NetworkClientState *cs, Packet *p, char* buffer, size_t
++pos;
}
p->pos = pos;
str_validate(bufp);
}
// If PacketSize changes of size, you have to change the 2 packet->size