https://bugs.openldap.org/show_bug.cgi?id=9430

          Issue ID: 9430
           Summary: mdb_put() with MDB_RESERVE | MDB_NOOVERWRITE sets
                    'data' to invalid memory
           Product: LMDB
           Version: unspecified
          Hardware: x86_64
                OS: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: ---
         Component: liblmdb
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Running on NixOS (x86_64-linux).

The following sequence of methods was called with an MDB_env and MDB_txn
created with default flags, with the MDB_txn open on MAIN_DBI.

The following code is pseudocode - should the code not be clear enough, happy
to provide the original test case which was written in Zig
(https://ziglang.org).



    // Put KV pair ('hello', 'test').

    var k: MDB_val = .{ .mv_size = "hello".len, .mv_data = &"hello" };
    var v: MDB_val = .{ .mv_size = "test".len, .mv_data = &"test" };
    mdb_put(txn, MAIN_DBI, &k, &v, 0);

    // Attempt to put KV pair ('hello', 'world!') with MDB_RESERVE |
MDB_NOOVERWRITE, and assert that it fails.

    var k2: MDB_val = .{ .mv_size = "hello".len, .mv_data = &"hello" };
    var v2: MDB_val = .{ .mv_size = "world!".len, .mv_data = null };
    assert(mdb_put(txn, MAIN_DBI, &k2, &v2, MDB_RESERVE | MDB_NOOVERWRITE) ==
MDB_KEYEXIST);

    // Assertion fails.
    assert(v2 == v);



After these steps, it is expected that v2's 'mv_data' points to 'test' with a
'mv_size' of 4 (the previously, successfully-written KV pair).

What actually happened was that v2's 'mv_size' was correctly set to 4, though
'mv_data' points to garbage memory.

-- 
You are receiving this mail because:
You are on the CC list for the issue.

Reply via email to