[Forensics-changes] [yara] 247/407: Minor style changes

Hilko Bengen bengen at moszumanska.debian.org
Sat Jul 1 10:28:31 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 0bb3273e7d493b0c82e97f029657b31b1505a7aa
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Tue Dec 2 10:03:18 2014 +0100

    Minor style changes
---
 libyara/proc.c | 39 ++++++++++++++++++++++-----------------
 1 file changed, 22 insertions(+), 17 deletions(-)

diff --git a/libyara/proc.c b/libyara/proc.c
index 5694a1f..c7fd3b5 100644
--- a/libyara/proc.c
+++ b/libyara/proc.c
@@ -267,9 +267,11 @@ int yr_process_get_memory(
 
   YR_MEMORY_BLOCK* new_block;
   YR_MEMORY_BLOCK* current_block = NULL;
-  int mem = -1;
+
   FILE *maps = NULL;
-  int ret;
+
+  int mem = -1;
+  int result;
   int attached = 0;
 
   *first_block = NULL;
@@ -280,8 +282,8 @@ int yr_process_get_memory(
 
   if (maps == NULL)
   {
-    ret = ERROR_COULD_NOT_ATTACH_TO_PROCESS;
-    goto end;
+    result = ERROR_COULD_NOT_ATTACH_TO_PROCESS;
+    goto _exit;
   }
 
   snprintf(buffer, sizeof(buffer), "/proc/%u/mem", pid);
@@ -290,17 +292,20 @@ int yr_process_get_memory(
 
   if (mem == -1)
   {
-    ret = ERROR_COULD_NOT_ATTACH_TO_PROCESS;
-    goto end;
+    result = ERROR_COULD_NOT_ATTACH_TO_PROCESS;
+    goto _exit;
   }
 
-  if (ptrace(PTRACE_ATTACH, pid, NULL, 0) == -1)
+  if (ptrace(PTRACE_ATTACH, pid, NULL, 0) != -1)
   {
-    ret = ERROR_COULD_NOT_ATTACH_TO_PROCESS;
-    goto end;
+    attached = 1;
+  }
+  else
+  {
+    result = ERROR_COULD_NOT_ATTACH_TO_PROCESS;
+    goto _exit;
   }
 
-  attached = 1;
   wait(NULL);
 
   while (fgets(buffer, sizeof(buffer), maps) != NULL)
@@ -313,8 +318,8 @@ int yr_process_get_memory(
 
     if (data == NULL)
     {
-      ret = ERROR_INSUFICIENT_MEMORY;
-      goto end;
+      result = ERROR_INSUFICIENT_MEMORY;
+      goto _exit;
     }
 
     if (pread(mem, data, length, begin) != -1)
@@ -323,8 +328,8 @@ int yr_process_get_memory(
 
       if (new_block == NULL)
       {
-        ret = ERROR_INSUFICIENT_MEMORY;
-        goto end;
+        result = ERROR_INSUFICIENT_MEMORY;
+        goto _exit;
       }
 
       if (*first_block == NULL)
@@ -347,9 +352,9 @@ int yr_process_get_memory(
     }
   }
 
-  ret = ERROR_SUCCESS;
+  result = ERROR_SUCCESS;
 
- end:
+_exit:
 
   if (attached)
     ptrace(PTRACE_DETACH, pid, NULL, 0);
@@ -360,7 +365,7 @@ int yr_process_get_memory(
   if (maps != NULL)
     fclose(maps);
 
-  if (data)
+  if (data != NULL)
     yr_free(data);
 
   return ret;

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