From bba10a7af4df8f943152607ded0c3d45460b1d73 Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 16 Feb 2006 18:39:25 +0000 Subject: Extra checking and exception handling in InspSocket::Write git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3228 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/socket.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/socket.cpp b/src/socket.cpp index da179d9c8..282d3c5a7 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -29,6 +29,7 @@ using namespace std; #include #include #include +#include #include "socket.h" #include "inspircd.h" #include "inspircd_io.h" @@ -241,7 +242,16 @@ char* InspSocket::Read() // and should be aborted. int InspSocket::Write(std::string data) { - this->Buffer.append(data); + try + { + if ((data != "") && (this->Buffer.length() + data.length() < this->Buffer.max_size())) + this->Buffer.append(data); + } + catch (std::length_error) + { + log(DEBUG,"std::length_error exception caught while appending to socket buffer!"); + return 0; + } return data.length(); } -- cgit v1.2.3