mrc0mmand / rpms / hivex

Forked from rpms/hivex 3 years ago
Clone

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

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