[Forensics-changes] [yara] 127/368: Fix bad returns.

Hilko Bengen bengen at moszumanska.debian.org
Sat Jul 1 10:30:19 UTC 2017


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

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

commit 868d6adf142a1669ddbbd33ed22e02086e7c8bc3
Author: Wesley Shields <wxs at atarininja.org>
Date:   Thu Dec 17 08:03:42 2015 -0800

    Fix bad returns.
    
    Fix cases where returning ERROR_WRONG_ARGUMENTS is the incorrect thing to do,
    because it causes execution of all rules to halt. The proper thing to do in
    these particular cases is to return UNDEFINED because we can't possibly do the
    requested operation given the argument values.
    
    Fixes #381.
---
 libyara/modules/math.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libyara/modules/math.c b/libyara/modules/math.c
index 869842f..e5ff873 100644
--- a/libyara/modules/math.c
+++ b/libyara/modules/math.c
@@ -82,7 +82,7 @@ define_function(data_entropy)
   YR_MEMORY_BLOCK* block = NULL;
   
   if (offset < 0 || length < 0 || offset < context->mem_block->base)
-    return ERROR_WRONG_ARGUMENTS;
+    return_float(UNDEFINED);
 
   data = (uint32_t*) yr_calloc(256, sizeof(uint32_t));
 
@@ -179,7 +179,7 @@ define_function(data_deviation)
   YR_MEMORY_BLOCK* block = NULL;
 
   if (offset < 0 || length < 0 || offset < context->mem_block->base)
-    return ERROR_WRONG_ARGUMENTS;
+    return_float(UNDEFINED);
  
   foreach_memory_block(context, block)
   {
@@ -249,7 +249,7 @@ define_function(data_mean)
   size_t i;
 
   if (offset < 0 || length < 0 || offset < context->mem_block->base)
-    return ERROR_WRONG_ARGUMENTS;
+    return_float(UNDEFINED);
  
   foreach_memory_block(context, block)
   {
@@ -311,7 +311,7 @@ define_function(data_serial_correlation)
   double scc = 0;
 
   if (offset < 0 || length < 0 || offset < context->mem_block->base)
-    return ERROR_WRONG_ARGUMENTS;
+    return_float(UNDEFINED);
  
   foreach_memory_block(context, block)
   {
@@ -422,7 +422,7 @@ define_function(data_monte_carlo_pi)
   YR_MEMORY_BLOCK* block = NULL;
 
   if (offset < 0 || length < 0 || offset < context->mem_block->base)
-    return ERROR_WRONG_ARGUMENTS;
+    return_float(UNDEFINED);
  
   foreach_memory_block(context, block)
   {

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