From 86ca408d469811d13a15d5c7a671feda38126eb0 Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 6 Mar 2009 01:23:25 +0000 Subject: (svn r15626) -Fix [FS#2698]: UTF8 string handling could cause buffer overruns. --- src/network/core/packet.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/network/core') 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 */ -- cgit v1.2.3-70-g09d2