aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/include/string_tools.h
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-06-09 20:01:56 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-06-19 17:52:39 +0100
commitf8213c0644ab6b809b586cb510da07984739938d (patch)
treefcca86f4744e2f8d5b2b6194179a9049edb13433 /contrib/epee/include/string_tools.h
parentMerge pull request #854 (diff)
downloadmonero-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 'contrib/epee/include/string_tools.h')
-rw-r--r--contrib/epee/include/string_tools.h4
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;