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.
This commit is contained in:
moneromooo-monero 2016-06-09 20:01:56 +01:00
parent 30ef965f9a
commit f8213c0644
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3

View File

@ -139,9 +139,11 @@ namespace string_tools
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
template<class CharT> 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(); res.clear();
if (!allow_partial_byte && (s.size() & 1))
return false;
try try
{ {
long v = 0; long v = 0;