diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-06-09 20:01:56 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-06-19 17:52:39 +0100 |
commit | f8213c0644ab6b809b586cb510da07984739938d (patch) | |
tree | fcca86f4744e2f8d5b2b6194179a9049edb13433 /contrib/epee/include/string_tools.h | |
parent | Merge pull request #854 (diff) | |
download | monero-f8213c0644ab6b809b586cb510da07984739938d.tar.xz |
Require 64/16 characters for payment ids
The default behavior for hex string parsing would allow the
last digit to be made from a single hexadecimal character,
which is correct, but we typically do not want that as it
gets confusing and easy to not spot wrong input size.
Diffstat (limited to '')
-rw-r--r-- | contrib/epee/include/string_tools.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/contrib/epee/include/string_tools.h b/contrib/epee/include/string_tools.h index 8289ee0ba..b973c6d48 100644 --- a/contrib/epee/include/string_tools.h +++ b/contrib/epee/include/string_tools.h @@ -139,9 +139,11 @@ namespace string_tools } //---------------------------------------------------------------------------- template<class CharT> - bool parse_hexstr_to_binbuff(const std::basic_string<CharT>& s, std::basic_string<CharT>& res) + bool parse_hexstr_to_binbuff(const std::basic_string<CharT>& s, std::basic_string<CharT>& res, bool allow_partial_byte = false) { res.clear(); + if (!allow_partial_byte && (s.size() & 1)) + return false; try { long v = 0; |