hivex/0002-handle-Check-that-page...

33 lines
869 B
Diff

From 4bbdf555f88baeae0fa804a369a81a83908bd705 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 30 Oct 2014 14:02:25 +0000
Subject: [PATCH 2/2] handle: Check that pages do not extend beyond the end of
the file.
Thanks: Mahmoud Al-Qudsi
---
lib/hivex.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/lib/hivex.c b/lib/hivex.c
index a3cbcf7..3a8f09b 100644
--- a/lib/hivex.c
+++ b/lib/hivex.c
@@ -247,6 +247,13 @@ hivex_open (const char *filename, int flags)
goto error;
}
+ if (off + page_size > h->size) {
+ SET_ERRNO (ENOTSUP,
+ "%s: page size %zu at 0x%zx extends beyond end of file, bad registry",
+ filename, page_size, off);
+ goto error;
+ }
+
/* Read the blocks in this page. */
size_t blkoff;
struct ntreg_hbin_block *block;
--
2.1.0