summaryrefslogtreecommitdiff
path: root/src/misc.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2012-09-01 18:54:51 -0400
committerAdam <Adam@anope.org>2012-09-01 18:54:51 -0400
commite3d5140dcc936ff411c438b7e3997104cb5f085a (patch)
tree49d7ee0b3e531a1c81e35fb10f25e6340fa781ba /src/misc.cpp
parentf81d0113a21187d68c5fa0f1262e5514465b1953 (diff)
Added a web panel module + a default template
Diffstat (limited to 'src/misc.cpp')
-rw-r--r--src/misc.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/misc.cpp b/src/misc.cpp
index 41f1370a1..ee091c249 100644
--- a/src/misc.cpp
+++ b/src/misc.cpp
@@ -758,9 +758,9 @@ void Anope::Unhex(const Anope::string &src, Anope::string &dest)
{
size_t len = src.length();
Anope::string rv;
- for (size_t i = 0; i < len; i += 2)
+ for (size_t i = 0; i + 1 < len; i += 2)
{
- char h = src[i], l = src[i + 1];
+ char h = std::tolower(src[i]), l = std::tolower(src[i + 1]);
unsigned char byte = (h >= 'a' ? h - 'a' + 10 : h - '0') << 4;
byte += (l >= 'a' ? l - 'a' + 10 : l - '0');
rv += byte;
@@ -768,17 +768,12 @@ void Anope::Unhex(const Anope::string &src, Anope::string &dest)
dest = rv;
}
-void Anope::Unhex(const Anope::string &src, char *dest)
+void Anope::Unhex(const Anope::string &src, char *dest, size_t sz)
{
- size_t len = src.length(), destpos = 0;
- for (size_t i = 0; i < len; i += 2)
- {
- char h = src[i], l = src[i + 1];
- unsigned char byte = (h >= 'a' ? h - 'a' + 10 : h - '0') << 4;
- byte += (l >= 'a' ? l - 'a' + 10 : l - '0');
- dest[destpos++] = byte;
- }
- dest[destpos] = 0;
+ Anope::string d;
+ Anope::Unhex(src, d);
+
+ strncpy(dest, d.c_str(), sz);
}
int Anope::LastErrorCode()