mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
merge bitcoin#23756: Fix implicit integer sign changes in strencodings
This commit is contained in:
parent
fa1a5d2100
commit
8c742e9d15
@ -91,7 +91,7 @@ std::vector<unsigned char> ParseHex(const char* psz)
|
|||||||
signed char c = HexDigit(*psz++);
|
signed char c = HexDigit(*psz++);
|
||||||
if (c == (signed char)-1)
|
if (c == (signed char)-1)
|
||||||
break;
|
break;
|
||||||
unsigned char n = (c << 4);
|
auto n{uint8_t(c << 4)};
|
||||||
c = HexDigit(*psz++);
|
c = HexDigit(*psz++);
|
||||||
if (c == (signed char)-1)
|
if (c == (signed char)-1)
|
||||||
break;
|
break;
|
||||||
@ -145,8 +145,7 @@ std::string EncodeBase64(const std::string& str)
|
|||||||
|
|
||||||
std::vector<unsigned char> DecodeBase64(const char* p, bool* pf_invalid)
|
std::vector<unsigned char> DecodeBase64(const char* p, bool* pf_invalid)
|
||||||
{
|
{
|
||||||
static const int decode64_table[256] =
|
static const int8_t decode64_table[256]{
|
||||||
{
|
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
-1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1,
|
-1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1,
|
||||||
@ -168,7 +167,7 @@ std::vector<unsigned char> DecodeBase64(const char* p, bool* pf_invalid)
|
|||||||
while (*p != 0) {
|
while (*p != 0) {
|
||||||
int x = decode64_table[(unsigned char)*p];
|
int x = decode64_table[(unsigned char)*p];
|
||||||
if (x == -1) break;
|
if (x == -1) break;
|
||||||
val.push_back(x);
|
val.push_back(uint8_t(x));
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,8 +223,7 @@ std::string EncodeBase32(const std::string& str, bool pad)
|
|||||||
|
|
||||||
std::vector<unsigned char> DecodeBase32(const char* p, bool* pf_invalid)
|
std::vector<unsigned char> DecodeBase32(const char* p, bool* pf_invalid)
|
||||||
{
|
{
|
||||||
static const int decode32_table[256] =
|
static const int8_t decode32_table[256]{
|
||||||
{
|
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, -1, -1, -1, -1,
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, -1, -1, -1, -1,
|
||||||
@ -247,7 +245,7 @@ std::vector<unsigned char> DecodeBase32(const char* p, bool* pf_invalid)
|
|||||||
while (*p != 0) {
|
while (*p != 0) {
|
||||||
int x = decode32_table[(unsigned char)*p];
|
int x = decode32_table[(unsigned char)*p];
|
||||||
if (x == -1) break;
|
if (x == -1) break;
|
||||||
val.push_back(x);
|
val.push_back(uint8_t(x));
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,14 +538,14 @@ std::string HexStr(const Span<const uint8_t> s)
|
|||||||
std::string ToLower(const std::string& str)
|
std::string ToLower(const std::string& str)
|
||||||
{
|
{
|
||||||
std::string r;
|
std::string r;
|
||||||
for (auto ch : str) r += ToLower((unsigned char)ch);
|
for (auto ch : str) r += ToLower(ch);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ToUpper(const std::string& str)
|
std::string ToUpper(const std::string& str)
|
||||||
{
|
{
|
||||||
std::string r;
|
std::string r;
|
||||||
for (auto ch : str) r += ToUpper((unsigned char)ch);
|
for (auto ch : str) r += ToUpper(ch);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ bool TimingResistantEqual(const T& a, const T& b)
|
|||||||
if (b.size() == 0) return a.size() == 0;
|
if (b.size() == 0) return a.size() == 0;
|
||||||
size_t accumulator = a.size() ^ b.size();
|
size_t accumulator = a.size() ^ b.size();
|
||||||
for (size_t i = 0; i < a.size(); i++)
|
for (size_t i = 0; i < a.size(); i++)
|
||||||
accumulator |= a[i] ^ b[i%b.size()];
|
accumulator |= size_t(a[i] ^ b[i%b.size()]);
|
||||||
return accumulator == 0;
|
return accumulator == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,6 @@ implicit-integer-sign-change:test/sighash_tests.cpp
|
|||||||
implicit-integer-sign-change:test/streams_tests.cpp
|
implicit-integer-sign-change:test/streams_tests.cpp
|
||||||
implicit-integer-sign-change:test/transaction_tests.cpp
|
implicit-integer-sign-change:test/transaction_tests.cpp
|
||||||
implicit-integer-sign-change:txmempool.cpp
|
implicit-integer-sign-change:txmempool.cpp
|
||||||
implicit-integer-sign-change:util/strencodings.*
|
|
||||||
implicit-integer-sign-change:validation.cpp
|
implicit-integer-sign-change:validation.cpp
|
||||||
implicit-integer-sign-change:zmq/zmqpublishnotifier.cpp
|
implicit-integer-sign-change:zmq/zmqpublishnotifier.cpp
|
||||||
implicit-signed-integer-truncation,implicit-integer-sign-change:chain.h
|
implicit-signed-integer-truncation,implicit-integer-sign-change:chain.h
|
||||||
|
Loading…
Reference in New Issue
Block a user