summaryrefslogtreecommitdiff
path: root/node/Utils.hpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2014-08-05 09:56:49 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2014-08-05 09:56:49 -0700
commite3c5ada3a70f71fe117319cd335a4462387c744d (patch)
tree795a9b772147b9ecf48471991ca5e5f7b341c316 /node/Utils.hpp
parent7adf0eac7e99337befb421d1b3cf2d64888a9ea2 (diff)
downloadinfinitytier-e3c5ada3a70f71fe117319cd335a4462387c744d.tar.gz
infinitytier-e3c5ada3a70f71fe117319cd335a4462387c744d.zip
Add signatures to Dictionary, and fix unhex() API in Utils to be a little safer.
Diffstat (limited to 'node/Utils.hpp')
-rw-r--r--node/Utils.hpp26
1 files changed, 7 insertions, 19 deletions
diff --git a/node/Utils.hpp b/node/Utils.hpp
index 4298d045..bafe0b39 100644
--- a/node/Utils.hpp
+++ b/node/Utils.hpp
@@ -145,11 +145,12 @@ public:
* This ignores all non-hex characters, just stepping over them and
* continuing. Upper and lower case are supported for letters a-f.
*
- * @param hex Hexadecimal ASCII code (non-hex chars are ignored)
+ * @param hex Hexadecimal ASCII code (non-hex chars are ignored, stops at zero or maxlen)
+ * @param maxlen Maximum length of hex string buffer
* @return Binary data
*/
- static std::string unhex(const char *hex);
- static inline std::string unhex(const std::string &hex) { return unhex(hex.c_str()); }
+ static std::string unhex(const char *hex,unsigned int maxlen);
+ static inline std::string unhex(const std::string &hex) { return unhex(hex.c_str(),(unsigned int)hex.length()); }
/**
* Convert hexadecimal to binary data
@@ -158,26 +159,13 @@ public:
* continuing. Upper and lower case are supported for letters a-f.
*
* @param hex Hexadecimal ASCII
+ * @param maxlen Maximum length of hex string buffer
* @param buf Buffer to fill
* @param len Length of buffer
* @return Number of characters actually written
*/
- static unsigned int unhex(const char *hex,void *buf,unsigned int len);
- static inline unsigned int unhex(const std::string &hex,void *buf,unsigned int len) { return unhex(hex.c_str(),buf,len); }
-
- /**
- * Convert hexadecimal to binary data
- *
- * This ignores all non-hex characters, just stepping over them and
- * continuing. Upper and lower case are supported for letters a-f.
- *
- * @param hex Hexadecimal ASCII
- * @param hexlen Length of hex ASCII
- * @param buf Buffer to fill
- * @param len Length of buffer
- * @return Number of bytes actually written to buffer
- */
- static unsigned int unhex(const char *hex,unsigned int hexlen,void *buf,unsigned int len);
+ static unsigned int unhex(const char *hex,unsigned int maxlen,void *buf,unsigned int len);
+ static inline unsigned int unhex(const std::string &hex,void *buf,unsigned int len) { return unhex(hex.c_str(),hex.length(),buf,len); }
/**
* Generate secure random bytes