From f8213c0644ab6b809b586cb510da07984739938d Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Thu, 9 Jun 2016 20:01:56 +0100 Subject: [PATCH] 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. --- contrib/epee/include/string_tools.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contrib/epee/include/string_tools.h b/contrib/epee/include/string_tools.h index 8289ee0b..b973c6d4 100644 --- a/contrib/epee/include/string_tools.h +++ b/contrib/epee/include/string_tools.h @@ -139,9 +139,11 @@ namespace string_tools } //---------------------------------------------------------------------------- template - bool parse_hexstr_to_binbuff(const std::basic_string& s, std::basic_string& res) + bool parse_hexstr_to_binbuff(const std::basic_string& s, std::basic_string& res, bool allow_partial_byte = false) { res.clear(); + if (!allow_partial_byte && (s.size() & 1)) + return false; try { long v = 0;