[Forensics-changes] [yara] 326/368: Fix segfault when yr_finalize is invoked without calling yr_initialize first
Hilko Bengen
bengen at moszumanska.debian.org
Sat Jul 1 10:30:53 UTC 2017
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to annotated tag v3.5.0
in repository yara.
commit 4cc5fccf9736e7bb1d423d9cd488b7e169ab6b88
Author: plusvic <plusvic at gmail.com>
Date: Thu Jun 16 13:07:00 2016 +0200
Fix segfault when yr_finalize is invoked without calling yr_initialize first
---
libyara/libyara.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/libyara/libyara.c b/libyara/libyara.c
index 2025d8b..3a019e5 100644
--- a/libyara/libyara.c
+++ b/libyara/libyara.c
@@ -96,11 +96,10 @@ YR_API int yr_initialize(void)
uint32_t def_stack_size = DEFAULT_STACK_SIZE;
int i;
- if (init_count > 0)
- {
- init_count++;
+ init_count++;
+
+ if (init_count > 1)
return ERROR_SUCCESS;
- }
for (i = 0; i < 256; i++)
{
@@ -137,8 +136,6 @@ YR_API int yr_initialize(void)
// Initialize default configuration options
FAIL_ON_ERROR(yr_set_configuration(YR_CONFIG_STACK_SIZE, &def_stack_size));
- init_count++;
-
return ERROR_SUCCESS;
}
@@ -169,9 +166,16 @@ YR_API int yr_finalize(void)
int i;
#endif
+ // yr_finalize shouldn't be called without calling yr_initialize first
+
+ if (init_count == 0)
+ return ERROR_INTERNAL_FATAL_ERROR;
+
yr_re_finalize_thread();
- if (--init_count > 0)
+ init_count--;
+
+ if (init_count > 0)
return ERROR_SUCCESS;
#ifdef HAVE_LIBCRYPTO
--
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