[Forensics-changes] [yara] 282/415: Fix issues with yr_arena_load

Hilko Bengen bengen at moszumanska.debian.org
Thu Apr 3 05:43:15 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch debian
in repository yara.

commit ebd0042383aef5ef72b701559cd4b91d20ee6c46
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Tue Dec 3 18:47:35 2013 +0100

    Fix issues with yr_arena_load
---
 libyara/arena.c | 23 ++++-------------------
 1 file changed, 4 insertions(+), 19 deletions(-)

diff --git a/libyara/arena.c b/libyara/arena.c
index 5564300..536fd8a 100644
--- a/libyara/arena.c
+++ b/libyara/arena.c
@@ -964,7 +964,7 @@ int yr_arena_load(
   uint8_t* reloc_target;
   long file_size;
 
-  fh = fopen(filename, "r");
+  fh = fopen(filename, "rb");
 
   if (fh == NULL)
     return ERROR_COULD_NOT_OPEN_FILE;
@@ -1000,7 +1000,7 @@ int yr_arena_load(
     return ERROR_UNSUPPORTED_FILE_VERSION;
   }
 
-  result = yr_arena_create(1024, 0, &new_arena);
+  result = yr_arena_create(header.size, 0, &new_arena);
 
   if (result != ERROR_SUCCESS)
   {
@@ -1008,23 +1008,8 @@ int yr_arena_load(
     return result;
   }
 
-  page = new_arena->page_list_head;
-
-  new_address = yr_realloc(
-      page->address,
-      header.size);
-
-  if (new_address != NULL)
-  {
-    page->address = new_address;
-  }
-  else
-  {
-    fclose(fh);
-    yr_arena_destroy(new_arena);
-    return ERROR_INSUFICIENT_MEMORY;
-  }
-
+  page = new_arena->current_page;
+  
   if (fread(page->address, header.size, 1, fh) != 1)
   {
     fclose(fh);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/forensics/yara.git



More information about the forensics-changes mailing list