summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-03-06 01:23:25 +0000
committerrubidium <rubidium@openttd.org>2009-03-06 01:23:25 +0000
commit34bd9ee636b43d1851d27f92884769f8f25717be (patch)
tree8972c2c7b9b1ab7c2b41b46cd9a44f1bb0fbd9bd /src/network
parent9c6d6c0d0edba265c73c04901d0f2155173407b8 (diff)
downloadopenttd-34bd9ee636b43d1851d27f92884769f8f25717be.tar.xz
(svn r15626) -Fix [FS#2698]: UTF8 string handling could cause buffer overruns.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/core/packet.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/network/core/packet.cpp b/src/network/core/packet.cpp
index 5c06ab488..013235d11 100644
--- a/src/network/core/packet.cpp
+++ b/src/network/core/packet.cpp
@@ -237,6 +237,7 @@ void Packet::Recv_string(char *buffer, size_t size, bool allow_newlines)
{
PacketSize pos;
char *bufp = buffer;
+ const char *last = buffer + size - 1;
/* Don't allow reading from a closed socket */
if (cs->HasClientQuit()) return;
@@ -253,7 +254,7 @@ void Packet::Recv_string(char *buffer, size_t size, bool allow_newlines)
}
this->pos = pos;
- str_validate(bufp, allow_newlines);
+ str_validate(bufp, last, allow_newlines);
}
#endif /* ENABLE_NETWORK */