mrc0mmand / rpms / hivex

Forked from rpms/hivex 3 years ago
Clone

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

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