summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hashcomp.cpp21
-rw-r--r--src/inspstring.cpp10
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp2
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp2
4 files changed, 7 insertions, 28 deletions
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp
index 4ddf942ea..a2f99b70c 100644
--- a/src/hashcomp.cpp
+++ b/src/hashcomp.cpp
@@ -365,27 +365,6 @@ irc::sepstream::~sepstream()
{
}
-std::string irc::hex(const unsigned char *raw, size_t rawsz)
-{
- if (!rawsz)
- return "";
-
- /* EWW! This used to be using sprintf, which is WAY inefficient. -Special */
-
- const char *hex = "0123456789abcdef";
- static char hexbuf[MAXBUF];
-
- size_t i, j;
- for (i = 0, j = 0; j < rawsz; ++j)
- {
- hexbuf[i++] = hex[raw[j] / 16];
- hexbuf[i++] = hex[raw[j] % 16];
- }
- hexbuf[i] = 0;
-
- return hexbuf;
-}
-
irc::modestacker::modestacker(bool add) : adding(add)
{
sequence.clear();
diff --git a/src/inspstring.cpp b/src/inspstring.cpp
index 72d6c64c8..7fa4762c5 100644
--- a/src/inspstring.cpp
+++ b/src/inspstring.cpp
@@ -23,16 +23,16 @@
static const char hextable[] = "0123456789abcdef";
-std::string BinToHex(const std::string& data)
+std::string BinToHex(const void* raw, size_t l)
{
- int l = data.length();
+ const char* data = static_cast<const char*>(raw);
std::string rv;
rv.reserve(l * 2);
- for(int i=0; i < l; i++)
+ for (size_t i = 0; i < l; i++)
{
unsigned char c = data[i];
- rv.append(1, hextable[c >> 4]);
- rv.append(1, hextable[c & 0xF]);
+ rv.push_back(hextable[c >> 4]);
+ rv.push_back(hextable[c & 0xF]);
}
return rv;
}
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index f85b886e1..2ae16c619 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -846,7 +846,7 @@ class ModuleSSLGnuTLS : public Module
}
else
{
- certinfo->fingerprint = irc::hex(digest, digest_size);
+ certinfo->fingerprint = BinToHex(digest, digest_size);
}
/* Beware here we do not check for errors.
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index b8f588b06..23e770c8b 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -635,7 +635,7 @@ class ModuleSSLOpenSSL : public Module
}
else
{
- certinfo->fingerprint = irc::hex(md, n);
+ certinfo->fingerprint = BinToHex(md, n);
}
if ((ASN1_UTCTIME_cmp_time_t(X509_get_notAfter(cert), ServerInstance->Time()) == -1) || (ASN1_UTCTIME_cmp_time_t(X509_get_notBefore(cert), ServerInstance->Time()) == 0))