Skip to content

Commit 81d1ca8

Browse files
committed
consistency
1 parent 022046f commit 81d1ca8

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/parse.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -830,17 +830,22 @@ impl KernelDumpParser {
830830

831831
/// Read an exact amount of virtual memory starting at `gva`. Returns `None`
832832
/// if a memory error occurs (page not present, page not in dump, etc.).
833-
pub fn virt_read_exact(&self, gva: Gva, buf: &mut [u8]) -> Result<bool> {
833+
pub fn virt_read_exact(&self, gva: Gva, buf: &mut [u8]) -> Result<Option<()>> {
834834
self.virt_read_exact_with_dtb(gva, buf, Gpa::new(self.headers.directory_table_base))
835835
}
836836

837837
/// Read an exact amount of virtual memory starting at `gva` using a
838838
/// specific directory table base / set of page tables. Returns `None` if a
839839
/// memory error occurs (page not present, page not in dump, etc.).
840-
pub fn virt_read_exact_with_dtb(&self, gva: Gva, buf: &mut [u8], dtb: Gpa) -> Result<bool> {
840+
pub fn virt_read_exact_with_dtb(
841+
&self,
842+
gva: Gva,
843+
buf: &mut [u8],
844+
dtb: Gpa,
845+
) -> Result<Option<()>> {
841846
match self.virt_read_exact_strict_with_dtb(gva, buf, dtb) {
842-
Ok(()) => Ok(true),
843-
Err(KdmpParserError::MemoryRead(_)) => Ok(false),
847+
Ok(()) => Ok(Some(())),
848+
Err(KdmpParserError::MemoryRead(_)) => Ok(None),
844849
Err(e) => Err(e),
845850
}
846851
}
@@ -969,9 +974,11 @@ impl KernelDumpParser {
969974
}
970975

971976
let mut buffer = vec![0; unicode_str.length.into()];
972-
if !self.virt_read_exact_with_dtb(Gva::new(unicode_str.buffer.into()), &mut buffer, dtb)? {
977+
let Some(()) =
978+
self.virt_read_exact_with_dtb(Gva::new(unicode_str.buffer.into()), &mut buffer, dtb)?
979+
else {
973980
return Ok(None);
974-
}
981+
};
975982

976983
let n = unicode_str.length / 2;
977984

tests/regression.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ fn regressions() {
597597
parser
598598
.virt_read_exact(Gva::new(0xfffff80122800000 + 0x100000 - 8), &mut buffer)
599599
.unwrap()
600+
.is_some()
600601
);
601602

602603
assert_eq!(buffer, [
@@ -625,6 +626,7 @@ fn regressions() {
625626
parser
626627
.virt_read_exact(Gva::new(0xfffff80122800000 + 0x200000 - 0x8), &mut buffer)
627628
.unwrap()
629+
.is_some()
628630
);
629631

630632
assert_eq!(buffer, [

0 commit comments

Comments
 (0)