Skip to content

Commit

Permalink
Fix/workaround crash under UBSAN on OpenFileGDB driver with test_ogrs…
Browse files Browse the repository at this point in the history
…f -all_drivers
  • Loading branch information
rouault committed Jan 10, 2025
1 parent 87d8e06 commit 0df468c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion autotest/ogr/ogr_basic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,11 @@ def test_ogr_basic_10():
if test_cli_utilities.get_test_ogrsf_path() is None:
pytest.skip()

# --config OPENFILEGDB_REPRODUCIBLE_UUID=YES helps avoiding unsigned-integer-overflow
# under UBSAN.
ret = gdaltest.runexternal(
test_cli_utilities.get_test_ogrsf_path() + " -all_drivers"
test_cli_utilities.get_test_ogrsf_path()
+ " -all_drivers --config OPENFILEGDB_REPRODUCIBLE_UUID=YES"
)

assert "INFO" in ret
Expand Down
4 changes: 3 additions & 1 deletion ogr/ogrsf_frmts/openfilegdb/ogropenfilegdb_generate_uuid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ std::string OFGDBGenerateUUID(bool bInit)
// from the same seed on all platforms.
const auto reproducibleRand = [&nCounterLocal]()
{
nCounterLocal = nCounterLocal * 1103515245U + 12345U;
nCounterLocal = static_cast<uint32_t>(
(static_cast<uint64_t>(nCounterLocal) * 1103515245U + 12345U) &
UINT32_MAX);
return (nCounterLocal / 65536U) % 32768U;
};

Expand Down

0 comments on commit 0df468c

Please sign in to comment.