[Forensics-changes] [yara] 76/368: Fix warnings

Hilko Bengen bengen at moszumanska.debian.org
Sat Jul 1 10:30:13 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 92fee0f10308e9419b725f02e92dc046d431d2c9
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Thu Sep 24 14:50:50 2015 +0200

    Fix warnings
---
 libyara/exec.c         |  2 +-
 libyara/modules/math.c | 39 ++++++++++++++++++++++++---------------
 libyara/modules/pe.c   | 10 +++++++---
 libyara/object.c       |  5 +++--
 libyara/re.c           |  6 +++---
 5 files changed, 38 insertions(+), 24 deletions(-)

diff --git a/libyara/exec.c b/libyara/exec.c
index dbb6d29..63f9b4e 100644
--- a/libyara/exec.c
+++ b/libyara/exec.c
@@ -852,7 +852,7 @@ int yr_execute_code(
         if (is_undef(r2))
           stack[sp - r1.i].i = UNDEFINED;
         else
-          stack[sp - r1.i].d = r2.i;
+          stack[sp - r1.i].d = (double) r2.i;
         break;
 
       case OP_STR_TO_BOOL:
diff --git a/libyara/modules/math.c b/libyara/modules/math.c
index c96de3e..869842f 100644
--- a/libyara/modules/math.c
+++ b/libyara/modules/math.c
@@ -35,7 +35,7 @@ double log2(double n)
 
 define_function(string_entropy)
 {
-  int i;
+  size_t i;
   double entropy = 0.0;
 
   SIZED_STRING* s = sized_string_argument(1);
@@ -67,10 +67,12 @@ define_function(string_entropy)
 
 define_function(data_entropy)
 {
-  int i, past_first_block = FALSE;
+  int past_first_block = FALSE;
   double entropy = 0.0;
 
   size_t total_len = 0;
+  size_t i;
+
   uint32_t* data;
 
   int64_t offset = integer_argument(1);   // offset where to start
@@ -92,7 +94,7 @@ define_function(data_entropy)
     if (offset >= block->base &&
         offset < block->base + block->size)
     {
-      size_t data_offset = offset - block->base;
+      size_t data_offset = (size_t) (offset - block->base);
       size_t data_len = (size_t) yr_min(
           length, (size_t) (block->size - data_offset));
 
@@ -151,7 +153,7 @@ define_function(string_deviation)
   double mean = float_argument(2);
   double sum = 0.0;
 
-  int i;
+  size_t i;
 
   for (i = 0; i < s->length; i++)
     sum += fabs(((double) s->c_string[i]) - mean);
@@ -162,7 +164,7 @@ define_function(string_deviation)
 
 define_function(data_deviation)
 {  
-  int i, past_first_block = FALSE;
+  int past_first_block = FALSE;
 
   int64_t offset = integer_argument(1);
   int64_t length = integer_argument(2);
@@ -171,6 +173,7 @@ define_function(data_deviation)
   double sum = 0.0;
 
   size_t total_len = 0;
+  size_t i;
 
   YR_SCAN_CONTEXT* context = scan_context();
   YR_MEMORY_BLOCK* block = NULL;
@@ -183,7 +186,7 @@ define_function(data_deviation)
     if (offset >= block->base &&
         offset < block->base + block->size)
     {
-      size_t data_offset = offset - block->base;
+      size_t data_offset = (size_t) (offset - block->base);
       size_t data_len = (size_t) yr_min(
           length, (size_t) (block->size - data_offset));
 
@@ -219,7 +222,7 @@ define_function(data_deviation)
 
 define_function(string_mean)
 {
-  int i;
+  size_t i;
   double sum = 0.0;
   
   SIZED_STRING* s = sized_string_argument(1);
@@ -233,7 +236,7 @@ define_function(string_mean)
 
 define_function(data_mean)
 {  
-  int i, past_first_block = FALSE;
+  int past_first_block = FALSE;
   double sum = 0.0;
 
   int64_t offset = integer_argument(1);
@@ -243,6 +246,7 @@ define_function(data_mean)
   YR_MEMORY_BLOCK* block = NULL;
 
   size_t total_len = 0;
+  size_t i;
 
   if (offset < 0 || length < 0 || offset < context->mem_block->base)
     return ERROR_WRONG_ARGUMENTS;
@@ -252,7 +256,7 @@ define_function(data_mean)
     if (offset >= block->base &&
         offset < block->base + block->size)
     {
-      size_t data_offset = offset - block->base;
+      size_t data_offset = (size_t) (offset - block->base);
       size_t data_len = (size_t) yr_min(
           length, (size_t) (block->size - data_offset));
 
@@ -288,8 +292,10 @@ define_function(data_mean)
 
 define_function(data_serial_correlation)
 {
-  int i, past_first_block = FALSE;
+  int past_first_block = FALSE;
+
   size_t total_len = 0;
+  size_t i;
 
   int64_t offset = integer_argument(1);
   int64_t length = integer_argument(2);
@@ -312,7 +318,7 @@ define_function(data_serial_correlation)
     if (offset >= block->base &&
         offset < block->base + block->size)
     {
-      size_t data_offset = offset - block->base;
+      size_t data_offset = (size_t) (offset - block->base);
       size_t data_len = (size_t) yr_min(
           length, (size_t) (block->size - data_offset));
 
@@ -373,7 +379,7 @@ define_function(string_serial_correlation)
   double scct3 = 0;
   double scc = 0;
 
-  int i;
+  size_t i;
 
   for (i = 0; i < s->length; i++)
   {
@@ -400,13 +406,15 @@ define_function(string_serial_correlation)
 
 define_function(data_monte_carlo_pi)
 {
-  int i, past_first_block = FALSE;
+  int past_first_block = FALSE;
   int mcount = 0;
   int inmont = 0;
 
   double INCIRC = pow(pow(256.0, 3.0) - 1, 2.0);
   double mpi = 0;
 
+  size_t i;
+
   int64_t offset = integer_argument(1);
   int64_t length = integer_argument(2);
 
@@ -423,7 +431,7 @@ define_function(data_monte_carlo_pi)
     {
       unsigned int monte[6];
 
-      size_t data_offset = offset - block->base;
+	  size_t data_offset = (size_t) (offset - block->base);
       size_t data_len = (size_t) yr_min(
           length, (size_t) (block->size - data_offset));
 
@@ -489,7 +497,8 @@ define_function(string_monte_carlo_pi)
 
   int mcount = 0;
   int inmont = 0;
-  int i;
+  
+  size_t i;
 
   for (i = 0; i < s->length; i++)
   {
diff --git a/libyara/modules/pe.c b/libyara/modules/pe.c
index cfc8416..603b9bb 100644
--- a/libyara/modules/pe.c
+++ b/libyara/modules/pe.c
@@ -1471,7 +1471,7 @@ define_function(exports)
   DWORD* names;
 
   int64_t offset;
-  int i;
+  uint32_t i;
 
   // If not a PE file, return UNDEFINED
 
@@ -1688,10 +1688,12 @@ define_function(imports_ordinal)
   YR_OBJECT* module = module();
   PE* pe = (PE*) module->data;
 
+  IMPORTED_DLL* imported_dll;
+
   if (!pe)
     return_integer(UNDEFINED);
 
-  IMPORTED_DLL* imported_dll = pe->imported_dlls;
+  imported_dll = pe->imported_dlls;
 
   while (imported_dll != NULL)
   {
@@ -1721,10 +1723,12 @@ define_function(imports_dll)
   YR_OBJECT* module = module();
   PE* pe = (PE*) module->data;
 
+  IMPORTED_DLL* imported_dll;
+
   if (!pe)
     return_integer(UNDEFINED);
 
-  IMPORTED_DLL* imported_dll = pe->imported_dlls;
+  imported_dll = pe->imported_dlls;
 
   while (imported_dll != NULL)
   {
diff --git a/libyara/object.c b/libyara/object.c
index b3f632c..a48fb47 100644
--- a/libyara/object.c
+++ b/libyara/object.c
@@ -1102,11 +1102,12 @@ void yr_object_print_data(
     case OBJECT_TYPE_STRING:
       if (((YR_OBJECT_STRING*) object)->value != NULL)
       {
+        size_t l;
         printf(" = \"");
 
-        for (i = 0; i < ((YR_OBJECT_STRING*) object)->value->length; i++)
+        for (l = 0; l < ((YR_OBJECT_STRING*) object)->value->length; l++)
         {
-          char c = ((YR_OBJECT_STRING*) object)->value->c_string[i];
+          char c = ((YR_OBJECT_STRING*) object)->value->c_string[l];
 
           if (isprint(c))
             printf("%c", c);
diff --git a/libyara/re.c b/libyara/re.c
index ff9b1e3..49df79c 100644
--- a/libyara/re.c
+++ b/libyara/re.c
@@ -1618,7 +1618,7 @@ int yr_re_exec(
   max_count = (int) yr_min(input_size, RE_SCAN_LIMIT);
 
   // Round down max_count to a multiple of character_size, this way if
-  // character_size is 2 and input_size is impair we are ignoring the
+  // character_size is 2 and input_size is odd we are ignoring the
   // extra byte which can't match anyways.
 
   max_count = max_count - max_count % character_size;
@@ -1779,14 +1779,14 @@ int yr_re_exec(
 
         case RE_OPCODE_MATCH_AT_START:
           if (flags & RE_FLAGS_BACKWARDS)
-            kill = input_size > count;
+            kill = input_size > (size_t) count;
           else
             kill = (flags & RE_FLAGS_NOT_AT_START) || (count != 0);
           action = kill ? ACTION_KILL : ACTION_CONTINUE;
           break;
 
         case RE_OPCODE_MATCH_AT_END:
-          action = input_size > count ? ACTION_KILL : ACTION_CONTINUE;
+          action = input_size > (size_t) count ? ACTION_KILL : ACTION_CONTINUE;
           break;
 
         case RE_OPCODE_MATCH:

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