Merge bitcoin/bitcoin#30248: refactor: Add explicit cast to expected_last_page to silence fuzz ISan

fa9cb101cf refactor: Add explicit cast to expected_last_page to silence fuzz ISan (MarcoFalke)

Pull request description:

  Fixes #30247

  I don't think this implicit cast can lead to any bugs, so make it explicit to silence the fuzz integer sanitizer.

  Can be tested with:

  ```
  FUZZ=wallet_bdb_parser UBSAN_OPTIONS="suppressions=$(pwd)/test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1:report_error_type=1" ./src/test/fuzz/fuzz /tmp/1376869be72eebcc87fe737020add634b1a29533
  ```

  After downloading the raw fuzz input from 1376869be7

ACKs for top commit:
  dergoegge:
    utACK fa9cb101cf

Tree-SHA512: 226dcc58be8d70b4eec1657f232c9c6648b5dac5eb2706e7390e65ce0a031fbaf8afce97d71a535c8294467dca4757c96f294d8cc03d5e6a1c0a036b0e070325
This commit is contained in:
merge-script 2024-06-20 09:43:26 +01:00
commit c6de072a21
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1

View file

@ -551,7 +551,7 @@ void BerkeleyRODatabase::Open()
// }
// Check the last page number
uint32_t expected_last_page = (size / page_size) - 1;
uint32_t expected_last_page{uint32_t((size / page_size) - 1)};
if (outer_meta.last_page != expected_last_page) {
throw std::runtime_error("Last page number could not fit in file");
}