Skip to content

NULL dereference: DB_ENV->rep_get_nsites() and DB_TXN method gaps in __cdsgroup_begin #149

Description

@gburd

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

  1. 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.
  2. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions