Mercurial > hg
comparison rust/hg-core/src/dirstate_tree/dirstate_map.rs @ 47675:48aec076b8fb
dirstate-v2: Enforce data size read from the docket file
The data file may not be shorter than its size given by the docket.
It may be longer, but additional data is ignored.
Differential Revision: https://phab.mercurial-scm.org/D11089
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Mon, 12 Jul 2021 22:46:52 +0200 |
parents | ff97e793ed36 |
children | 065e61628980 |
comparison
equal
deleted
inserted
replaced
47674:ff97e793ed36 | 47675:48aec076b8fb |
---|---|
408 ignore_patterns_hash: [0; on_disk::IGNORE_PATTERNS_HASH_LEN], | 408 ignore_patterns_hash: [0; on_disk::IGNORE_PATTERNS_HASH_LEN], |
409 } | 409 } |
410 } | 410 } |
411 | 411 |
412 #[timed] | 412 #[timed] |
413 pub fn new_v2(on_disk: &'on_disk [u8]) -> Result<Self, DirstateError> { | 413 pub fn new_v2( |
414 Ok(on_disk::read(on_disk)?) | 414 on_disk: &'on_disk [u8], |
415 data_size: usize, | |
416 ) -> Result<Self, DirstateError> { | |
417 if let Some(data) = on_disk.get(..data_size) { | |
418 Ok(on_disk::read(data)?) | |
419 } else { | |
420 Err(DirstateV2ParseError.into()) | |
421 } | |
415 } | 422 } |
416 | 423 |
417 #[timed] | 424 #[timed] |
418 pub fn new_v1( | 425 pub fn new_v1( |
419 on_disk: &'on_disk [u8], | 426 on_disk: &'on_disk [u8], |