[Forensics-changes] [yara] 118/192: Use set_sized_string for setting version in dot net module. (#621)

Hilko Bengen bengen at moszumanska.debian.org
Sat Jul 1 10:31:54 UTC 2017


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

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

commit d52e9e6f19b5862fbbb602b95977b2f2e17bed9f
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Wed Mar 15 17:39:47 2017 +0100

    Use set_sized_string for setting version in dot net module. (#621)
    
    The existing code was going a very long path to do the same thing.
---
 libyara/modules/dotnet.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/libyara/modules/dotnet.c b/libyara/modules/dotnet.c
index a9a2cfc..13f4c20 100644
--- a/libyara/modules/dotnet.c
+++ b/libyara/modules/dotnet.c
@@ -1504,7 +1504,6 @@ void dotnet_parse_com(
   PCLI_HEADER cli_header;
   PNET_METADATA metadata;
   int64_t metadata_root, offset;
-  char *version;
   STREAMS headers;
   WORD num_streams;
 
@@ -1537,14 +1536,7 @@ void dotnet_parse_com(
     return;
   }
 
-  version = (char*) yr_malloc(metadata->Length + 1);
-
-  if (!version)
-    return;
-
-  strncpy(version, metadata->Version, metadata->Length);
-  set_string(version, pe->object, "version");
-  yr_free(version);
+  set_sized_string(metadata->Version, metadata->Length, pe->object, "version");
 
   // The metadata structure has some variable length records after the version.
   // We must manually parse things from here on out.

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