mrc0mmand / rpms / hivex

Forked from rpms/hivex 3 years ago
Clone

Blame SOURCES/0005-handle-Refuse-to-open-files-8192-bytes-in-size.patch

3d1215
From ebcb61e3d88d99b929b4d8ccaad837a871c102d8 Mon Sep 17 00:00:00 2001
3d1215
From: "Richard W.M. Jones" <rjones@redhat.com>
3d1215
Date: Thu, 30 Oct 2014 13:50:39 +0000
3d1215
Subject: [PATCH 05/12] handle: Refuse to open files < 8192 bytes in size.
3d1215
3d1215
These cannot be valid hives, since they don't contain a full header
3d1215
page and at least a single page of data (in other words they couldn't
3d1215
contain a root node).
3d1215
3d1215
Thanks: Mahmoud Al-Qudsi
3d1215
(cherry picked from commit 357f26fa64fd1d9ccac2331fe174a8ee9c607adb)
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 62a8644..a3cbcf7 100644
3d1215
--- a/lib/handle.c
3d1215
+++ b/lib/handle.c
3d1215
@@ -104,6 +104,13 @@ hivex_open (const char *filename, int flags)
3d1215
 
3d1215
   h->size = statbuf.st_size;
3d1215
 
3d1215
+  if (h->size < 0x2000) {
3d1215
+    SET_ERRNO (EINVAL,
3d1215
+               "%s: file is too small to be a Windows NT Registry hive file",
3d1215
+               filename);
3d1215
+    goto error;
3d1215
+  }
3d1215
+
3d1215
   if (!h->writable) {
3d1215
     h->addr = mmap (NULL, h->size, PROT_READ, MAP_SHARED, h->fd, 0);
3d1215
     if (h->addr == MAP_FAILED)
3d1215
-- 
3d1215
1.8.3.1
3d1215