summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/extra/m_httpd.cpp21
-rw-r--r--modules/extra/m_ssl.cpp13
2 files changed, 13 insertions, 21 deletions
diff --git a/modules/extra/m_httpd.cpp b/modules/extra/m_httpd.cpp
index 03e130068..bdb3ed602 100644
--- a/modules/extra/m_httpd.cpp
+++ b/modules/extra/m_httpd.cpp
@@ -45,6 +45,7 @@ class MyHTTPClient : public HTTPClient
Reference<HTTPPage> page;
Anope::string ip;
+ Anope::string inbuf;
unsigned content_length;
Anope::string post_data;
@@ -111,19 +112,23 @@ class MyHTTPClient : public HTTPClient
bool Read(const char *buffer, size_t l) anope_override
{
- Anope::string buf(buffer, l);
+ inbuf.append(buffer, l);
- if (!this->header_done)
+ for (size_t nl; !this->header_done && (nl = inbuf.find('\n')) != Anope::string::npos;)
{
- Anope::string token;
- sepstream sep(buf, '\n');
- while (sep.GetToken(token) && !token.trim().empty())
+ Anope::string token = inbuf.substr(0, nl).trim();
+ inbuf = inbuf.substr(nl + 1);
+
+ if (token.empty())
+ this->header_done = true;
+ else
this->Read(token);
- this->header_done = true;
- buf = sep.GetRemaining();
}
- this->post_data += buf;
+ if (!this->header_done)
+ return true;
+
+ this->post_data += inbuf;
if (this->post_data.length() >= this->content_length)
{
diff --git a/modules/extra/m_ssl.cpp b/modules/extra/m_ssl.cpp
index 10d1b5807..c1ba3f76a 100644
--- a/modules/extra/m_ssl.cpp
+++ b/modules/extra/m_ssl.cpp
@@ -116,7 +116,6 @@ class SSLModule : public Module
Anope::string context_name = "Anope";
SSL_CTX_set_session_id_context(client_ctx, reinterpret_cast<const unsigned char *>(context_name.c_str()), context_name.length());
SSL_CTX_set_session_id_context(server_ctx, reinterpret_cast<const unsigned char *>(context_name.c_str()), context_name.length());
-
}
~SSLModule()
@@ -144,11 +143,7 @@ class SSLModule : public Module
if (Anope::IsFile(this->certfile.c_str()))
{
if (!SSL_CTX_use_certificate_file(client_ctx, this->certfile.c_str(), SSL_FILETYPE_PEM) || !SSL_CTX_use_certificate_file(server_ctx, this->certfile.c_str(), SSL_FILETYPE_PEM))
- {
- SSL_CTX_free(client_ctx);
- SSL_CTX_free(server_ctx);
throw ConfigException("Error loading certificate");
- }
else
Log(LOG_DEBUG) << "m_ssl: Successfully loaded certificate " << this->certfile;
}
@@ -158,22 +153,14 @@ class SSLModule : public Module
if (Anope::IsFile(this->keyfile.c_str()))
{
if (!SSL_CTX_use_PrivateKey_file(client_ctx, this->keyfile.c_str(), SSL_FILETYPE_PEM) || !SSL_CTX_use_PrivateKey_file(server_ctx, this->keyfile.c_str(), SSL_FILETYPE_PEM))
- {
- SSL_CTX_free(client_ctx);
- SSL_CTX_free(server_ctx);
throw ConfigException("Error loading private key");
- }
else
Log(LOG_DEBUG) << "m_ssl: Successfully loaded private key " << this->keyfile;
}
else
{
if (Anope::IsFile(this->certfile.c_str()))
- {
- SSL_CTX_free(client_ctx);
- SSL_CTX_free(server_ctx);
throw ConfigException("Error loading private key " + this->keyfile + " - file not found");
- }
else
Log() << "Unable to open private key " << this->keyfile;
}