[Forensics-changes] [yara] 57/135: Replace uint8_t* type with RE_CODE for regular expression code
Hilko Bengen
bengen at moszumanska.debian.org
Sat Jul 1 10:27:32 UTC 2017
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to annotated tag v3.1.0
in repository yara.
commit a9fd7f2c0dd45bb11ff99ac27be9e89591e71e54
Author: Victor M. Alvarez <plusvic at gmail.com>
Date: Tue Jul 15 12:13:52 2014 +0200
Replace uint8_t* type with RE_CODE for regular expression code
---
libyara/include/yara/modules.h | 10 +++++++---
libyara/include/yara/re.h | 11 ++++++-----
libyara/modules/cuckoo.c | 7 +------
libyara/re.c | 10 +++++-----
4 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/libyara/include/yara/modules.h b/libyara/include/yara/modules.h
index 92d0e33..9ed3a60 100644
--- a/libyara/include/yara/modules.h
+++ b/libyara/include/yara/modules.h
@@ -147,7 +147,7 @@ limitations under the License.
#define integer_argument(n) (((int64_t*) args)[n-1])
#define string_argument(n) ((char*)((int64_t*) args)[n-1])
-#define regexp_argument(n) ((uint8_t*)((int64_t*) args)[n-1])
+#define regexp_argument(n) ((RE_CODE)((int64_t*) args)[n-1])
#define self() (function_obj->parent_obj)
@@ -184,7 +184,9 @@ limitations under the License.
function_obj->return_obj->type == OBJECT_TYPE_INTEGER, \
"return type differs from function declaration"); \
yr_object_set_integer( \
- (integer), function_obj->return_obj, NULL); \
+ (integer), \
+ function_obj->return_obj, \
+ NULL); \
return ERROR_SUCCESS; \
}
@@ -194,7 +196,9 @@ limitations under the License.
function_obj->return_obj->type == OBJECT_TYPE_STRING, \
"return type differs from function declaration"); \
yr_object_set_string( \
- (string), function_obj->return_obj, NULL); \
+ ((string) != UNDEFINED) ? (string) : NULL, \
+ function_obj->return_obj, \
+ NULL); \
return ERROR_SUCCESS; \
}
diff --git a/libyara/include/yara/re.h b/libyara/include/yara/re.h
index 054ac24..ad1ee15 100644
--- a/libyara/include/yara/re.h
+++ b/libyara/include/yara/re.h
@@ -79,6 +79,7 @@ typedef struct RE RE;
typedef struct RE_NODE RE_NODE;
typedef struct RE_ERROR RE_ERROR;
+typedef uint8_t* RE_CODE;
#define CHAR_IN_CLASS(chr, cls) \
((cls)[(chr) / 8] & 1 << ((chr) % 8))
@@ -106,8 +107,8 @@ struct RE_NODE
RE_NODE* left;
RE_NODE* right;
- uint8_t* forward_code;
- uint8_t* backward_code;
+ RE_CODE forward_code;
+ RE_CODE backward_code;
};
@@ -116,7 +117,7 @@ struct RE {
uint32_t flags;
RE_NODE* root_node;
YR_ARENA* code_arena;
- uint8_t* code;
+ RE_CODE code;
};
@@ -202,7 +203,7 @@ int yr_re_emit_code(
int yr_re_exec(
- uint8_t* re_code,
+ RE_CODE re_code,
uint8_t* input,
size_t input_size,
int flags,
@@ -211,7 +212,7 @@ int yr_re_exec(
int yr_re_match(
- uint8_t* re_code,
+ RE_CODE re_code,
const char* target);
diff --git a/libyara/modules/cuckoo.c b/libyara/modules/cuckoo.c
index 76f13eb..b7128d4 100644
--- a/libyara/modules/cuckoo.c
+++ b/libyara/modules/cuckoo.c
@@ -60,7 +60,7 @@ define_function(network_dns_lookup)
uint64_t http_request(
YR_OBJECT* network_obj,
- uint8_t* uri_regexp,
+ RE_CODE uri_regexp,
int methods)
{
json_t* network_json = (json_t*) network_obj->data;
@@ -269,8 +269,3 @@ int module_unload(YR_OBJECT* module)
return ERROR_SUCCESS;
}
-
-
-
-
-#undef MODULE_NAME
\ No newline at end of file
diff --git a/libyara/re.c b/libyara/re.c
index 581dbaa..ce8256d 100644
--- a/libyara/re.c
+++ b/libyara/re.c
@@ -60,7 +60,7 @@ order to avoid confusion with operating system threads.
typedef struct _RE_FIBER
{
- uint8_t* ip;
+ RE_CODE ip;
int32_t sp;
uint16_t stack[RE_MAX_STACK];
@@ -336,7 +336,7 @@ int yr_re_compile(
int yr_re_match(
- uint8_t* re_code,
+ RE_CODE re_code,
const char* target)
{
return yr_re_exec(
@@ -1452,7 +1452,7 @@ void _yr_re_fiber_sync(
// Executes a regular expression
//
// Args:
-// uint8_t* re_code - Pointer to regexp code be executed
+// RE_CODE re_code - Regexp code be executed
// uint8_t* input - Pointer to input data
// size_t input_size - Input data size
// int flags - Flags:
@@ -1471,18 +1471,18 @@ void _yr_re_fiber_sync(
// -2 An error ocurred
int yr_re_exec(
- uint8_t* re_code,
+ RE_CODE re_code,
uint8_t* input_data,
size_t input_size,
int flags,
RE_MATCH_CALLBACK_FUNC callback,
void* callback_args)
{
- uint8_t* ip;
uint8_t* input;
uint8_t mask;
uint8_t value;
+ RE_CODE ip;
RE_FIBER_LIST fibers;
RE_THREAD_STORAGE* storage;
RE_FIBER* fiber;
--
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