Skip to content
Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rwmjones committed Oct 30, 2014
1 parent 914d9b9 commit 357f26f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/handle.c
Expand Up @@ -104,6 +104,13 @@ hivex_open (const char *filename, int flags)

h->size = statbuf.st_size;

if (h->size < 0x2000) {
SET_ERRNO (EINVAL,
"%s: file is too small to be a Windows NT Registry hive file",
filename);
goto error;
}

if (!h->writable) {
h->addr = mmap (NULL, h->size, PROT_READ, MAP_SHARED, h->fd, 0);
if (h->addr == MAP_FAILED)
Expand Down

0 comments on commit 357f26f

Please sign in to comment.