Two more public-API NULL-dereference paths found while building the coverage drivers in #147.
1. rep_get_nsites() on an unopened repmgr handle
Calling DB_ENV->rep_get_nsites() before the environment is opened dereferences a NULL. The guard that should catch this, ENV_NOT_CONFIGURED, is a no-op before open (src/dbinc/db_int.in:604), so the pre-open case falls straight through. Reproducible in ~12 lines of public API.
2. __cdsgroup_begin installs only 8 of DB_TXN's 12 methods
The CDS group transaction handle leaves get_priority, set_priority, set_commit_token and set_txn_lsnp as NULL function pointers. Calling any of them on a CDS group txn jumps to 0x0 rather than returning an error.
Both are reachable from documented public APIs with no invalid arguments — just an unexpected call order or an access method whose handle is less fully populated than the type implies.
Suggested fix
- Make the pre-open case an explicit error (or make
ENV_NOT_CONFIGURED meaningful before open) for rep_get_nsites and audit its siblings for the same shape.
- Populate the missing
DB_TXN slots in __cdsgroup_begin with functions that return EINVAL/DB_OPNOTSUP, so an unsupported operation is reported rather than crashing. Worth checking every handle constructor that hand-installs a subset of a method table.
Not fixed in #147, which was scoped to tests only.
Two more public-API NULL-dereference paths found while building the coverage drivers in #147.
1.
rep_get_nsites()on an unopened repmgr handleCalling
DB_ENV->rep_get_nsites()before the environment is opened dereferences a NULL. The guard that should catch this,ENV_NOT_CONFIGURED, is a no-op before open (src/dbinc/db_int.in:604), so the pre-open case falls straight through. Reproducible in ~12 lines of public API.2.
__cdsgroup_begininstalls only 8 ofDB_TXN's 12 methodsThe CDS group transaction handle leaves
get_priority,set_priority,set_commit_tokenandset_txn_lsnpas NULL function pointers. Calling any of them on a CDS group txn jumps to0x0rather than returning an error.Both are reachable from documented public APIs with no invalid arguments — just an unexpected call order or an access method whose handle is less fully populated than the type implies.
Suggested fix
ENV_NOT_CONFIGUREDmeaningful before open) forrep_get_nsitesand audit its siblings for the same shape.DB_TXNslots in__cdsgroup_beginwith functions that returnEINVAL/DB_OPNOTSUP, so an unsupported operation is reported rather than crashing. Worth checking every handle constructor that hand-installs a subset of a method table.Not fixed in #147, which was scoped to tests only.