[Forensics-changes] [yara] 49/415: Add missing weight.c and weight.h
Hilko Bengen
bengen at moszumanska.debian.org
Thu Apr 3 05:42:43 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 fd9ccb5095fb1307a3f0dd9a3b5ba49a657a46ad
Author: Victor M. Alvarez <plusvic at gmail.com>
Date: Sun Dec 6 14:50:18 2009 +0000
Add missing weight.c and weight.h
---
libyara/Makefile | 4 ++--
libyara/scan.c | 4 ++--
libyara/weight.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
libyara/weight.h | 25 +++++++++++++++++++++++++
4 files changed, 74 insertions(+), 4 deletions(-)
diff --git a/libyara/Makefile b/libyara/Makefile
index 22d79fe..550e3f3 100644
--- a/libyara/Makefile
+++ b/libyara/Makefile
@@ -126,7 +126,7 @@ INSTALL_DATA = ${INSTALL} -m 644
INSTALL_PROGRAM = ${INSTALL}
INSTALL_SCRIPT = ${INSTALL}
INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
-LD = /usr/libexec/gcc/i686-apple-darwin10/4.0.1/ld
+LD = /Developer/usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld
LDFLAGS =
LEX = flex
LEXLIB = -lfl
@@ -139,7 +139,7 @@ LN_S = ln -s
LTLIBOBJS =
MAKEINFO = ${SHELL} /Users/plusvic/Projects/yara/libyara/missing --run makeinfo
MKDIR_P = ./install-sh -c -d
-NM = /usr/bin/nm
+NM = /Developer/usr/bin/nm
NMEDIT = nmedit
OBJEXT = o
OTOOL = otool
diff --git a/libyara/scan.c b/libyara/scan.c
index 706f327..3b07401 100644
--- a/libyara/scan.c
+++ b/libyara/scan.c
@@ -207,7 +207,7 @@ int hex_match(unsigned char* buffer, unsigned int buffer_size, unsigned char* pa
}
}
- else if ((buffer[b] & mask[m]) == pattern[p])
+ else if ((buffer[b] & mask[m]) == pattern[p]) // TODO: This is the most common case, maybe could be checked first for speed optimization
{
b++;
m++;
@@ -651,7 +651,7 @@ int find_matches_for_strings( STRING_LIST_ENTRY* first_string,
{
match = string->matches;
- while(match != NULL)
+ while(match != NULL) // TODO: Possible optimization: is enough to check the only last match instead of all the previous ones?
{
if (match->offset + match->length > current_file_offset)
{
diff --git a/libyara/weight.c b/libyara/weight.c
new file mode 100644
index 0000000..26607a7
--- /dev/null
+++ b/libyara/weight.c
@@ -0,0 +1,45 @@
+/*
+
+Copyright(c) 2007. Victor M. Alvarez [plusvic at gmail.com].
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+*/
+
+#include "weight.h"
+
+int string_weight(STRING* string, int multiplier)
+{
+ int len;
+
+ if (IS_REGEXP(string))
+ {
+ return (16 * multiplier);
+ }
+ else
+ {
+ len = string->length;
+
+ if (len > 8)
+ {
+ return (1 * multiplier);
+ }
+ else if (len > 4)
+ {
+ return (2 * multiplier);
+ }
+ else
+ {
+ return (4 * multiplier);
+ }
+ }
+}
+
diff --git a/libyara/weight.h b/libyara/weight.h
new file mode 100644
index 0000000..5de7ad8
--- /dev/null
+++ b/libyara/weight.h
@@ -0,0 +1,25 @@
+/*
+
+Copyright(c) 2007. Victor M. Alvarez [plusvic at gmail.com].
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+*/
+
+#ifndef _SIZEDSTR_H
+#define _SIZEDSTR_H
+
+#include "yara.h"
+
+int calculate_string_weight(STRING* string);
+
+#endif
+
--
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