pijul nest
guest [sign in]

Don't load pages past the end of the file

pmeunier
Jan 1, 2022, 11:08 AM
AI4NKV4J2AXQ4BVFUI7ZWPJO6BCQEBJACZGIXF2EMGFUWEM3X2ZAC

Dependencies

  • [2] ECPAFJSB add env_borrow for Txn and MutTxn
  • [3] OP6SVMOD Resetting history
  • [4] W2MIZD5B Single file databases + CRC for the root pages (checking the other pages makes everything very slow)
  • [5] YXKP4AIW New file locks, with multiple sets of free pages
  • [*] WS4ZQM4R Debugging, tests, etc.
  • [*] E4MD6T3L Proofreading and commenting of this crate (massive bug fixes included)

Change contents

  • edit in sanakirja/src/lib.rs at line 131
    [3.80036]
    [3.80036]
    /// Corruption error
    #[error("Corruption error: offset {0} is past the end of the file")]
    Corrupt(u64),
  • edit in sanakirja/src/environment/muttxn.rs at line 622
    [7.39867]
    [3.90908]
    if off > self.length {
    return Err(Error::Corrupt(off))
    }
  • edit in sanakirja/src/environment/mod.rs at line 462
    [8.29235]
    [2.123]
    pub(crate) size: u64,
  • edit in sanakirja/src/environment/mod.rs at line 496
    [3.105950]
    [3.105950]
    };
    // Load the header from the root page of this transaction, and
    // get its length. This is used as a check to avoid loading a
    // page past the end of the file.
    let size = unsafe {
    let next_page_ptr = env_.mmaps.lock()[0].ptr.offset((root * PAGE_SIZE) as isize);
    let header = GlobalHeader::from_le(&*(next_page_ptr as *const GlobalHeader));
    header.length
  • edit in sanakirja/src/environment/mod.rs at line 506
    [3.105961]
    [3.5873]
  • replacement in sanakirja/src/environment/mod.rs at line 508
    [3.5904][3.5014:5044](),[3.105961][3.5014:5044]()
    Ok(Txn { env, root })
    [3.5904]
    [3.5905]
    Ok(Txn { env, root, size })
  • edit in sanakirja/src/environment/mod.rs at line 567
    [7.40013]
    [3.106458]
    if off > self.size {
    return Err(Error::Corrupt(off))
    }