From 047e29179766076146e7bd6126a883f4f3c95150 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Fri, 17 May 2013 01:34:25 +0100 Subject: Reserve ServerLimits::MaxLine instead of MAXBUF. --- src/modules/extra/m_ldapauth.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules/extra') diff --git a/src/modules/extra/m_ldapauth.cpp b/src/modules/extra/m_ldapauth.cpp index 2d1551b43..ebfefd02b 100644 --- a/src/modules/extra/m_ldapauth.cpp +++ b/src/modules/extra/m_ldapauth.cpp @@ -212,7 +212,7 @@ public: std::string> &replacements) { std::string result; - result.reserve(MAXBUF); + result.reserve(ServerInstance->Config->Limits.MaxLine); for (unsigned int i = 0; i < text.length(); ++i) { char c = text[i]; -- cgit v1.2.3 From cc79342f50ce345657fca16c90f1d37a9228d8ad Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Fri, 17 May 2013 01:35:04 +0100 Subject: Compare to ServerLimits::MaxLine instead of MAXBUF. --- src/modules/extra/m_ldapauth.cpp | 2 +- src/modules/m_alias.cpp | 2 +- src/modules/m_blockcaps.cpp | 2 +- src/modules/m_spanningtree/utils.cpp | 2 +- src/users.cpp | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/modules/extra') diff --git a/src/modules/extra/m_ldapauth.cpp b/src/modules/extra/m_ldapauth.cpp index ebfefd02b..0a0698fc2 100644 --- a/src/modules/extra/m_ldapauth.cpp +++ b/src/modules/extra/m_ldapauth.cpp @@ -212,7 +212,7 @@ public: std::string> &replacements) { std::string result; - result.reserve(ServerInstance->Config->Limits.MaxLine); + result.reserve(text.length()); for (unsigned int i = 0; i < text.length(); ++i) { char c = text[i]; diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index 7e15b8c04..7343dd21b 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -309,7 +309,7 @@ class ModuleAlias : public Module void DoCommand(const std::string& newline, User* user, Channel *chan, const std::string &original_line) { std::string result; - result.reserve(ServerInstance->Config->Limits.MaxLine); + result.reserve(newline.length()); for (unsigned int i = 0; i < newline.length(); i++) { char c = newline[i]; diff --git a/src/modules/m_blockcaps.cpp b/src/modules/m_blockcaps.cpp index 0e1fa945f..c13549db8 100644 --- a/src/modules/m_blockcaps.cpp +++ b/src/modules/m_blockcaps.cpp @@ -119,7 +119,7 @@ public: ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, " out of range, setting to default of 100."); percent = 100; } - if (minlen < 1 || minlen > MAXBUF-1) + if (minlen < 1 || minlen > ServerInstance->Config->Limits.MaxLine) { ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, " out of range, setting to default of 1."); minlen = 1; diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 47c5ad6e1..c469f41a2 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -197,7 +197,7 @@ void SpanningTreeUtilities::GetListOfServersForChannel(Channel* c, TreeServerLis std::string SpanningTreeUtilities::ConstructLine(const std::string& prefix, const std::string& command, const parameterlist& params) { std::string FullLine; - FullLine.reserve(ServerInstance->Config->Limits.MaxLine); + FullLine.reserve(1024); FullLine = ":" + prefix + " " + command; for (parameterlist::const_iterator x = params.begin(); x != params.end(); ++x) { diff --git a/src/users.cpp b/src/users.cpp index 656d260e1..cd458f68e 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -443,7 +443,7 @@ void UserIOHandler::OnDataReady() case '\n': goto eol_found; } - if (line.length() < MAXBUF - 2) + if (line.length() < ServerInstance->Config->Limits.MaxLine - 2) line.push_back(c); } // if we got here, the recvq ran out before we found a newline @@ -995,10 +995,10 @@ void LocalUser::Write(const std::string& text) if (!ServerInstance->SE->BoundsCheckFd(&eh)) return; - if (text.length() > MAXBUF - 2) + if (text.length() > ServerInstance->Config->Limits.MaxLine - 2) { // this should happen rarely or never. Crop the string at 512 and try again. - std::string try_again = text.substr(0, MAXBUF - 2); + std::string try_again = text.substr(0, ServerInstance->Config->Limits.MaxLine - 2); Write(try_again); return; } -- cgit v1.2.3 From 37d97550b147e0d14f6a9e279f8505b7d49c84bb Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Wed, 22 May 2013 21:18:50 +0100 Subject: Convert a ton of uses of MAXBUF to use a fixed buffer size. --- src/configparser.cpp | 2 +- src/logger.cpp | 4 ++-- src/modules/extra/m_mssql.cpp | 4 ++-- src/modules/extra/m_ssl_gnutls.cpp | 4 ++-- src/modules/m_ident.cpp | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/modules/extra') diff --git a/src/configparser.cpp b/src/configparser.cpp index 61cdb55fa..31d314148 100644 --- a/src/configparser.cpp +++ b/src/configparser.cpp @@ -327,7 +327,7 @@ void ParseStack::DoReadFile(const std::string& key, const std::string& name, int file_cache& cache = FilesOutput[key]; cache.clear(); - char linebuf[MAXBUF*10]; + char linebuf[5120]; while (fgets(linebuf, sizeof(linebuf), file)) { size_t len = strlen(linebuf); diff --git a/src/logger.cpp b/src/logger.cpp index 1a63499d6..03960f4a1 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -116,10 +116,10 @@ void LogManager::OpenFileLogs() std::map::iterator fwi = logmap.find(target); if (fwi == logmap.end()) { - char realtarget[MAXBUF]; + char realtarget[256]; time_t time = ServerInstance->Time(); struct tm *mytime = gmtime(&time); - strftime(realtarget, MAXBUF, target.c_str(), mytime); + strftime(realtarget, sizeof(realtarget), target.c_str(), mytime); FILE* f = fopen(realtarget, "a"); fw = new FileWriter(f); logmap.insert(std::make_pair(target, fw)); diff --git a/src/modules/extra/m_mssql.cpp b/src/modules/extra/m_mssql.cpp index 244aa0922..9d9622fde 100644 --- a/src/modules/extra/m_mssql.cpp +++ b/src/modules/extra/m_mssql.cpp @@ -472,8 +472,8 @@ class SQLConn : public classbase if (sock->res_info->row_count > 0) { int cols = sock->res_info->num_cols; - char** name = new char*[MAXBUF]; - char** data = new char*[MAXBUF]; + char** name = new char*[512]; + char** data = new char*[512]; for (int j=0; jcurrent_results->columns[j]; diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index 8faee2da7..f9fddd5a1 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -803,8 +803,8 @@ class ModuleSSLGnuTLS : public Module int ret; unsigned int cert_list_size; gnutls_x509_crt_t cert; - char name[MAXBUF]; - unsigned char digest[MAXBUF]; + char name[512]; + unsigned char digest[512]; size_t digest_size = sizeof(digest); size_t name_size = sizeof(name); ssl_cert* certinfo = new ssl_cert; diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index 00ff75f59..9f67a6242 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -213,8 +213,8 @@ class IdentRequestSocket : public EventHandler /* We don't really need to buffer for incomplete replies here, since IDENT replies are * extremely short - there is *no* sane reason it'd be in more than one packet */ - char ibuf[MAXBUF]; - int recvresult = ServerInstance->SE->Recv(this, ibuf, MAXBUF-1, 0); + char ibuf[256]; + int recvresult = ServerInstance->SE->Recv(this, ibuf, sizeof(ibuf)-1, 0); /* Close (but don't delete from memory) our socket * and flag as done since the ident lookup has finished -- cgit v1.2.3