Skip to content

Commit 357f26f

Browse files
committed
handle: Refuse to open files < 8192 bytes in size.
These cannot be valid hives, since they don't contain a full header page and at least a single page of data (in other words they couldn't contain a root node). Thanks: Mahmoud Al-Qudsi
1 parent 914d9b9 commit 357f26f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: lib/handle.c

+7
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ hivex_open (const char *filename, int flags)
104104

105105
h->size = statbuf.st_size;
106106

107+
if (h->size < 0x2000) {
108+
SET_ERRNO (EINVAL,
109+
"%s: file is too small to be a Windows NT Registry hive file",
110+
filename);
111+
goto error;
112+
}
113+
107114
if (!h->writable) {
108115
h->addr = mmap (NULL, h->size, PROT_READ, MAP_SHARED, h->fd, 0);
109116
if (h->addr == MAP_FAILED)

0 commit comments

Comments
 (0)