diff options
author | Adam <Adam@anope.org> | 2012-09-01 18:54:51 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2012-09-01 18:54:51 -0400 |
commit | e3d5140dcc936ff411c438b7e3997104cb5f085a (patch) | |
tree | 49d7ee0b3e531a1c81e35fb10f25e6340fa781ba /src/misc.cpp | |
parent | f81d0113a21187d68c5fa0f1262e5514465b1953 (diff) |
Added a web panel module + a default template
Diffstat (limited to 'src/misc.cpp')
-rw-r--r-- | src/misc.cpp | 19 |
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() |