Skip to content

Commit

Permalink
Merge #5906: backport: trivial 2024 02 27
Browse files Browse the repository at this point in the history
a852a91 Merge bitcoin#25697: depends: expat 2.4.8 & fix building with -flto (fanquake)
587c335 Merge bitcoin#22485: doc: BaseIndex sync behavior with empty datadir (MacroFake)
aaa170a Merge bitcoin#25605: depends: update urls for dmg tools (fanquake)
7cbf69d Merge bitcoin#24319: refactor: Avoid unsigned integer overflow in core_write (MarcoFalke)
002db51 Merge bitcoin#24191: refactor: Make MessageBoxFlags enum underlying type unsigned (MarcoFalke)
9302737 Merge bitcoin#24059: Fix implicit-integer-sign-change in arith_uint256 (MarcoFalke)
7e57600 Merge bitcoin#23992: fuzz: Limit fuzzed time to years 2000-2100 (MarcoFalke)
cd13274 Merge bitcoin#23626: refactor: Fix implicit-signed-integer-truncation in cuckoocache.h (fanquake)
2a4558b Merge bitcoin#23553: test: Remove sanitizer suppression implicit-signed-integer-truncation:netaddress.cpp (fanquake)
75c877d Merge bitcoin#22584: test: Add temporary sanitizer suppression implicit-signed-integer-truncation:netaddress.cpp (MarcoFalke)
c342ce9 Merge bitcoin#22146: Reject invalid coin height and output index when loading assumeutxo (MarcoFalke)
0557c32 Merge bitcoin#22202: test: Add temporary coinstats suppressions (MarcoFalke)
3450fa5 Merge bitcoin#21846: fuzz: Add `-fsanitize=integer` suppression needed for RPC fuzzer (`generateblock`) (MarcoFalke)

Pull request description:

  ## Issue being fixed or feature implemented
  Batch of trivial backports

  ## What was done?

  ## How Has This Been Tested?
  Building locally; tests not ran

  ## Breaking Changes

  ## Checklist:
    _Go over all the following points, and put an `x` in all the boxes that apply._
  - [ ] I have performed a self-review of my own code
  - [ ] I have commented my code, particularly in hard-to-understand areas
  - [ ] I have added or updated relevant unit/integration/functional/e2e tests
  - [ ] I have made corresponding changes to the documentation
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

Top commit has no ACKs.

Tree-SHA512: 42e7fa81ce409917b36fa761b6a48a3869f5efe7287b8f02bb120036d6b7a6ff3463477cce4bcf87957f24c9128abcfbce4dfe0c4a0a3a52f9690527f49294f2
  • Loading branch information
PastaPastaPasta committed Feb 28, 2024
2 parents 41eb1b2 + a852a91 commit 59bf5cd
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 19 deletions.
9 changes: 6 additions & 3 deletions depends/packages/expat.mk
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package=expat
$(package)_version=2.4.1
$(package)_version=2.4.8
$(package)_download_path=https://github.com/libexpat/libexpat/releases/download/R_$(subst .,_,$($(package)_version))/
$(package)_file_name=$(package)-$($(package)_version).tar.xz
$(package)_sha256_hash=cf032d0dba9b928636548e32b327a2d66b1aab63c4f4a13dd132c2d1d2f2fb6a
$(package)_sha256_hash=f79b8f904b749e3e0d20afeadecf8249c55b2e32d4ebb089ae378df479dcaf25

# -D_DEFAULT_SOURCE defines __USE_MISC, which exposes additional
# definitions in endian.h, which are required for a working
# endianess check in configure when building with -flto.
define $(package)_set_vars
$(package)_config_opts=--disable-shared --without-docbook --without-tests --without-examples
$(package)_config_opts += --disable-dependency-tracking --enable-option-checking
$(package)_config_opts += --without-xmlwf
$(package)_config_opts_linux=--with-pic
$(package)_cflags += -fno-lto
$(package)_cppflags += -D_DEFAULT_SOURCE
endef

define $(package)_config_cmds
Expand Down
2 changes: 1 addition & 1 deletion depends/packages/native_ds_store.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package=native_ds_store
$(package)_version=1.3.0
$(package)_download_path=https://github.com/al45tair/ds_store/archive/
$(package)_download_path=https://github.com/dmgbuild/ds_store/archive/
$(package)_file_name=v$($(package)_version).tar.gz
$(package)_sha256_hash=76b3280cd4e19e5179defa23fb594a9dd32643b0c80d774bd3108361d94fb46d
$(package)_install_libdir=$(build_prefix)/lib/python3/dist-packages
Expand Down
2 changes: 1 addition & 1 deletion depends/packages/native_mac_alias.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package=native_mac_alias
$(package)_version=2.2.0
$(package)_download_path=https://github.com/al45tair/mac_alias/archive/
$(package)_download_path=https://github.com/dmgbuild/mac_alias/archive/
$(package)_file_name=v$($(package)_version).tar.gz
$(package)_sha256_hash=421e6d7586d1f155c7db3e7da01ca0dacc9649a509a253ad7077b70174426499
$(package)_install_libdir=$(build_prefix)/lib/python3/dist-packages
Expand Down
4 changes: 2 additions & 2 deletions src/arith_uint256.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ base_uint<BITS>& base_uint<BITS>::operator/=(const base_uint& b)
while (shift >= 0) {
if (num >= div) {
num -= div;
pn[shift / 32] |= (1 << (shift & 31)); // set a bit of the result.
pn[shift / 32] |= (1U << (shift & 31)); // set a bit of the result.
}
div >>= 1; // shift back.
shift--;
Expand Down Expand Up @@ -231,7 +231,7 @@ uint32_t arith_uint256::GetCompact(bool fNegative) const
nCompact >>= 8;
nSize++;
}
assert((nCompact & ~0x007fffff) == 0);
assert((nCompact & ~0x007fffffU) == 0);
assert(nSize < 256);
nCompact |= nSize << 24;
nCompact |= (fNegative && (nCompact & 0x007fffff) ? 0x00800000 : 0);
Expand Down
2 changes: 1 addition & 1 deletion src/core_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ std::string FormatScript(const CScript& script)
ret += strprintf("0x%x ", HexStr(std::vector<uint8_t>(it2, script.end())));
break;
}
return ret.substr(0, ret.size() - 1);
return ret.substr(0, ret.empty() ? ret.npos : ret.size() - 1);
}

const std::map<unsigned char, std::string> mapSigHashTypes = {
Expand Down
4 changes: 2 additions & 2 deletions src/cuckoocache.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class bit_packed_atomic_flags
*/
inline void bit_set(uint32_t s)
{
mem[s >> 3].fetch_or(1 << (s & 7), std::memory_order_relaxed);
mem[s >> 3].fetch_or(uint8_t(1 << (s & 7)), std::memory_order_relaxed);
}

/** bit_unset marks an entry as something that should not be overwritten.
Expand All @@ -102,7 +102,7 @@ class bit_packed_atomic_flags
*/
inline void bit_unset(uint32_t s)
{
mem[s >> 3].fetch_and(~(1 << (s & 7)), std::memory_order_relaxed);
mem[s >> 3].fetch_and(uint8_t(~(1 << (s & 7))), std::memory_order_relaxed);
}

/** bit_is_set queries the table for discardability at `s`.
Expand Down
4 changes: 4 additions & 0 deletions src/index/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ bool BaseIndex::Init()
} else {
m_best_block_index = m_chainstate->m_blockman.FindForkInGlobalIndex(active_chain, locator);
}

// Note: this will latch to true immediately if the user starts up with an empty
// datadir and an index enabled. If this is the case, indexation will happen solely
// via `BlockConnected` signals until, possibly, the next restart.
m_synced = m_best_block_index.load() == active_chain.Tip();
if (!m_synced) {
bool prune_violation = false;
Expand Down
4 changes: 4 additions & 0 deletions src/index/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class BaseIndex : public CValidationInterface
/// Whether the index is in sync with the main chain. The flag is flipped
/// from false to true once, after which point this starts processing
/// ValidationInterface notifications to stay in sync.
///
/// Note that this will latch to true *immediately* upon startup if
/// `m_chainstate->m_chain` is empty, which will be the case upon startup
/// with an empty datadir if, e.g., `-txindex=1` is specified.
std::atomic<bool> m_synced{false};

/// The last block in the chain that the index is in sync with.
Expand Down
3 changes: 1 addition & 2 deletions src/node/ui_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ class CClientUIInterface
{
public:
/** Flags for CClientUIInterface::ThreadSafeMessageBox */
enum MessageBoxFlags
{
enum MessageBoxFlags : uint32_t {
ICON_INFORMATION = 0,
ICON_WARNING = (1U << 0),
ICON_ERROR = (1U << 1),
Expand Down
4 changes: 2 additions & 2 deletions src/test/fuzz/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ void FillNode(FuzzedDataProvider& fuzzed_data_provider, CNode& node, bool init_v
int64_t ConsumeTime(FuzzedDataProvider& fuzzed_data_provider, const std::optional<int64_t>& min, const std::optional<int64_t>& max) noexcept
{
// Avoid t=0 (1970-01-01T00:00:00Z) since SetMockTime(0) disables mocktime.
static const int64_t time_min = ParseISO8601DateTime("1970-01-01T00:00:01Z");
static const int64_t time_max = ParseISO8601DateTime("9999-12-31T23:59:59Z");
static const int64_t time_min{ParseISO8601DateTime("2000-01-01T00:00:01Z")};
static const int64_t time_max{ParseISO8601DateTime("2100-12-31T23:59:59Z")};
return fuzzed_data_provider.ConsumeIntegralInRange<int64_t>(min.value_or(time_min), max.value_or(time_max));
}

Expand Down
8 changes: 8 additions & 0 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5898,6 +5898,14 @@ bool ChainstateManager::PopulateAndValidateSnapshot(
coins_count - coins_left);
return false;
}
if (coin.nHeight > base_height ||
outpoint.n >= std::numeric_limits<decltype(outpoint.n)>::max() // Avoid integer wrap-around in coinstats.cpp:ApplyHash
) {
LogPrintf("[snapshot] bad snapshot data after deserializing %d coins\n",
coins_count - coins_left);
return false;
}

coins_cache.EmplaceCoinInternalDANGER(std::move(outpoint), std::move(coin));

--coins_left;
Expand Down
6 changes: 1 addition & 5 deletions test/sanitizer_suppressions/ubsan
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ unsigned-integer-overflow:chain.h
unsigned-integer-overflow:coded_stream.h
unsigned-integer-overflow:coins.cpp
unsigned-integer-overflow:compressor.cpp
unsigned-integer-overflow:core_write.cpp
unsigned-integer-overflow:crypto/
# unsigned-integer-overflow in FuzzedDataProvider's ConsumeIntegralInRange
unsigned-integer-overflow:FuzzedDataProvider.h
Expand All @@ -48,7 +47,6 @@ implicit-integer-sign-change:*/include/boost/
implicit-integer-sign-change:*/include/c++/
implicit-integer-sign-change:*/new_allocator.h
implicit-integer-sign-change:addrman.h
implicit-integer-sign-change:arith_uint256.cpp
implicit-integer-sign-change:bech32.cpp
implicit-integer-sign-change:bloom.cpp
implicit-integer-sign-change:chain.cpp
Expand All @@ -61,7 +59,6 @@ implicit-integer-sign-change:crypto/
# implicit-integer-sign-change in FuzzedDataProvider's ConsumeIntegralInRange
implicit-integer-sign-change:FuzzedDataProvider.h
implicit-integer-sign-change:key.cpp
implicit-integer-sign-change:noui.cpp
implicit-integer-sign-change:policy/fees.cpp
implicit-integer-sign-change:prevector.h
implicit-integer-sign-change:script/bitcoinconsensus.cpp
Expand All @@ -86,10 +83,9 @@ implicit-signed-integer-truncation:addrman.cpp
implicit-signed-integer-truncation:addrman.h
implicit-signed-integer-truncation:chain.h
implicit-signed-integer-truncation:crypto/
implicit-signed-integer-truncation:cuckoocache.h
implicit-signed-integer-truncation:leveldb/
implicit-signed-integer-truncation:miner.cpp
implicit-signed-integer-truncation:net.cpp
implicit-signed-integer-truncation:net_processing.cpp
implicit-signed-integer-truncation:streams.h
implicit-signed-integer-truncation:test/arith_uint256_tests.cpp
implicit-signed-integer-truncation:test/skiplist_tests.cpp
Expand Down

0 comments on commit 59bf5cd

Please sign in to comment.