Skip to content

Commit 0df468c

Browse files
committed
Fix/workaround crash under UBSAN on OpenFileGDB driver with test_ogrsf -all_drivers
1 parent 87d8e06 commit 0df468c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

autotest/ogr/ogr_basic_test.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,11 @@ def test_ogr_basic_10():
448448
if test_cli_utilities.get_test_ogrsf_path() is None:
449449
pytest.skip()
450450

451+
# --config OPENFILEGDB_REPRODUCIBLE_UUID=YES helps avoiding unsigned-integer-overflow
452+
# under UBSAN.
451453
ret = gdaltest.runexternal(
452-
test_cli_utilities.get_test_ogrsf_path() + " -all_drivers"
454+
test_cli_utilities.get_test_ogrsf_path()
455+
+ " -all_drivers --config OPENFILEGDB_REPRODUCIBLE_UUID=YES"
453456
)
454457

455458
assert "INFO" in ret

ogr/ogrsf_frmts/openfilegdb/ogropenfilegdb_generate_uuid.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ std::string OFGDBGenerateUUID(bool bInit)
7777
// from the same seed on all platforms.
7878
const auto reproducibleRand = [&nCounterLocal]()
7979
{
80-
nCounterLocal = nCounterLocal * 1103515245U + 12345U;
80+
nCounterLocal = static_cast<uint32_t>(
81+
(static_cast<uint64_t>(nCounterLocal) * 1103515245U + 12345U) &
82+
UINT32_MAX);
8183
return (nCounterLocal / 65536U) % 32768U;
8284
};
8385

0 commit comments

Comments
 (0)