[Forensics-changes] [yara] 405/415: Use memcpy instead of strcpy in yr_strdup cause memcpy is probably faster

Hilko Bengen bengen at moszumanska.debian.org
Thu Apr 3 05:43:29 UTC 2014


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

bengen pushed a commit to branch debian
in repository yara.

commit c11eae21a55b0631986b5b579e9764be29a85c53
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Tue Feb 25 13:44:59 2014 +0100

    Use memcpy instead of strcpy in yr_strdup cause memcpy is probably faster
---
 libyara/mem.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libyara/mem.c b/libyara/mem.c
index d4eaaf0..d3eeeae 100644
--- a/libyara/mem.c
+++ b/libyara/mem.c
@@ -17,6 +17,7 @@ limitations under the License.
 #ifdef WIN32
 
 #include <windows.h>
+#include <string.h>
 
 static HANDLE hHeap;
 
@@ -52,13 +53,13 @@ void yr_free(void* ptr)
 
 char* yr_strdup(const char *str)
 {
-  size_t len = strlen(str);
-  char *dup = yr_malloc(len + 1);
+  size_t len = strlen(str) + 1;
+  void *dup = yr_malloc(len);
 
   if (dup != NULL)
-    strcpy(dup, str);
+    memcpy(dup, str, len);
 
-  return dup;
+  return (char*) dup;
 }
 
 #else

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