mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-20 13:37:28 +02:00
Don't rely on locale dependent functions in base_blob<BITS>::SetHex(...) (uint256), DecodeBase58(...), ParseMoney(...) and ParseHex(...)
This commit is contained in:
parent
f4e4ea1cee
commit
15db77f4dd
6 changed files with 25 additions and 13 deletions
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <hash.h>
|
||||
#include <uint256.h>
|
||||
#include <utilstrencodings.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
|
@ -34,7 +35,7 @@ static const int8_t mapBase58[256] = {
|
|||
bool DecodeBase58(const char* psz, std::vector<unsigned char>& vch)
|
||||
{
|
||||
// Skip leading spaces.
|
||||
while (*psz && isspace(*psz))
|
||||
while (*psz && IsSpace(*psz))
|
||||
psz++;
|
||||
// Skip and count leading '1's.
|
||||
int zeroes = 0;
|
||||
|
|
@ -48,7 +49,7 @@ bool DecodeBase58(const char* psz, std::vector<unsigned char>& vch)
|
|||
std::vector<unsigned char> b256(size);
|
||||
// Process the characters.
|
||||
static_assert(sizeof(mapBase58)/sizeof(mapBase58[0]) == 256, "mapBase58.size() should be 256"); // guarantee not out of range
|
||||
while (*psz && !isspace(*psz)) {
|
||||
while (*psz && !IsSpace(*psz)) {
|
||||
// Decode base58 character
|
||||
int carry = mapBase58[(uint8_t)*psz];
|
||||
if (carry == -1) // Invalid b58 character
|
||||
|
|
@ -64,7 +65,7 @@ bool DecodeBase58(const char* psz, std::vector<unsigned char>& vch)
|
|||
psz++;
|
||||
}
|
||||
// Skip trailing spaces.
|
||||
while (isspace(*psz))
|
||||
while (IsSpace(*psz))
|
||||
psz++;
|
||||
if (*psz != 0)
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue