Blame SOURCES/0006-handle-Check-that-pages-do-not-extend-beyond-the-end.patch

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