[Forensics-changes] [yara] 387/407: Fix a segfault under low memory conditions

Hilko Bengen bengen at moszumanska.debian.org
Sat Jul 1 10:28:48 UTC 2017


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

bengen pushed a commit to annotated tag v3.3.0
in repository yara.

commit febeaa2a8ad15a70f76f7fb7c1c5de4774159c05
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Fri Feb 6 20:55:04 2015 +0100

    Fix a segfault under low memory conditions
    
    yr_atoms_extract_from_re and  yr_atoms_extract_from_re functions were returning a non-null list of atoms even if failing, a segfault occurred while the calling function tried to destroy the returned list which was already destroyed.
---
 libyara/atoms.c | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/libyara/atoms.c b/libyara/atoms.c
index 8317699..3b478aa 100644
--- a/libyara/atoms.c
+++ b/libyara/atoms.c
@@ -1056,7 +1056,10 @@ int yr_atoms_extract_from_re(
 
     FAIL_ON_ERROR_WITH_CLEANUP(
         yr_atoms_extract_triplets(re->root_node, &triplet_atoms),
-        yr_atoms_list_destroy(*atoms));
+        {
+          yr_atoms_list_destroy(*atoms);
+          *atoms = NULL;
+        });
 
     if (min_atom_quality < yr_atoms_min_quality(triplet_atoms))
     {
@@ -1073,7 +1076,10 @@ int yr_atoms_extract_from_re(
   {
     FAIL_ON_ERROR_WITH_CLEANUP(
         _yr_atoms_wide(*atoms, &wide_atoms),
-        yr_atoms_list_destroy(*atoms));
+        {
+          yr_atoms_list_destroy(*atoms);
+          *atoms = NULL;
+        });
 
     if (flags & STRING_GFLAGS_ASCII)
     {
@@ -1090,7 +1096,10 @@ int yr_atoms_extract_from_re(
   {
     FAIL_ON_ERROR_WITH_CLEANUP(
         _yr_atoms_case_insentive(*atoms, &case_insentive_atoms),
-        yr_atoms_list_destroy(*atoms));
+        {
+          yr_atoms_list_destroy(*atoms);
+          *atoms = NULL;
+        });
 
     *atoms = _yr_atoms_list_concat(*atoms, case_insentive_atoms);
   }
@@ -1158,7 +1167,10 @@ int yr_atoms_extract_from_string(
   {
     FAIL_ON_ERROR_WITH_CLEANUP(
         _yr_atoms_wide(*atoms, &wide_atoms),
-        yr_atoms_list_destroy(*atoms));
+        {
+          yr_atoms_list_destroy(*atoms);
+          *atoms = NULL;
+        });
 
     if (flags & STRING_GFLAGS_ASCII)
     {
@@ -1175,7 +1187,10 @@ int yr_atoms_extract_from_string(
   {
     FAIL_ON_ERROR_WITH_CLEANUP(
         _yr_atoms_case_insentive(*atoms, &case_insentive_atoms),
-        yr_atoms_list_destroy(*atoms));
+        {
+          yr_atoms_list_destroy(*atoms);
+          *atoms = NULL;
+        });
 
     *atoms = _yr_atoms_list_concat(*atoms, case_insentive_atoms);
   }

-- 
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