[Forensics-changes] [yara] 03/06: Update signal handling test

Hilko Bengen bengen at moszumanska.debian.org
Sun Nov 13 00:39:15 UTC 2016


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

bengen pushed a commit to branch master
in repository yara.

commit 79db8b7a55149e1eea38e78114d32ae2361ee9a2
Author: Hilko Bengen <bengen at debian.org>
Date:   Mon Oct 31 23:30:37 2016 +0100

    Update signal handling test
---
 ...k-signals-when-setting-up-exception-handl.patch | 29 ++++++++++++----------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/debian/patches/0002-Don-t-unmask-signals-when-setting-up-exception-handl.patch b/debian/patches/0002-Don-t-unmask-signals-when-setting-up-exception-handl.patch
index d153771..1955f04 100644
--- a/debian/patches/0002-Don-t-unmask-signals-when-setting-up-exception-handl.patch
+++ b/debian/patches/0002-Don-t-unmask-signals-when-setting-up-exception-handl.patch
@@ -4,14 +4,15 @@ Subject: Don't unmask signals when setting up exception handler
 
 This is an adaptation of upstream commits
 8b2b6b8f82b8a8a8830bae122474b39ac2814fc6,
-0b3d9a93276d3364b2a3561995d27e8b4a137134.
+0b3d9a93276d3364b2a3561995d27e8b4a137134,
+ddd5e975f2c36323e408e0eeedd56db59e0148a0.
 ---
  Makefile.am            |   4 +-
  libyara/exception.h    |   7 +--
- tests/test-exception.c | 126 +++++++++++++++++++++++++++++++++++++++++++++++++
+ tests/test-exception.c | 128 +++++++++++++++++++++++++++++++++++++++++++++++++
  tests/util.c           |   2 +-
  tests/util.h           |  20 ++++++--
- 5 files changed, 147 insertions(+), 12 deletions(-)
+ 5 files changed, 149 insertions(+), 12 deletions(-)
  create mode 100644 tests/test-exception.c
 
 diff --git a/Makefile.am b/Makefile.am
@@ -65,10 +66,10 @@ index 436d006..c70ae63 100644
  #endif
 diff --git a/tests/test-exception.c b/tests/test-exception.c
 new file mode 100644
-index 0000000..8ebea58
+index 0000000..29232b2
 --- /dev/null
 +++ b/tests/test-exception.c
-@@ -0,0 +1,126 @@
+@@ -0,0 +1,128 @@
 +/*
 +Copyright (c) 2016. The YARA Authors. All Rights Reserved.
 +
@@ -107,11 +108,13 @@ index 0000000..8ebea58
 +#include <yara.h>
 +#include "util.h"
 +
++#define COUNT 128
++char wbuf[1024];
++
 +int main(int argc, char **argv)
 +{
 +  char* filename = strdup("yara-testblob.XXXXXX");
 +  int fd = mkstemp(filename);
-+  char wbuf[4096];
 +  int i;
 +
 +  if (fd <= 0)
@@ -124,21 +127,21 @@ index 0000000..8ebea58
 +
 +  memset(wbuf, 'a', sizeof(wbuf));
 +
-+  for (i = 0; i <= 3; i++)
++  for (i = 0; i < COUNT; i++)
 +    write(fd, wbuf, sizeof(wbuf));
 +
 +  uint8_t* mapped_region = mmap(
-+      NULL, 4 * sizeof(wbuf), PROT_READ, MAP_SHARED, fd, 0);
++      NULL, COUNT * sizeof(wbuf), PROT_READ, MAP_SHARED, fd, 0);
 +
-+  ftruncate(fd, 2 * sizeof(wbuf));
++  ftruncate(fd, COUNT * sizeof(wbuf) / 2);
 +
 +  /*
 +    mapped_region is now only partially backed by the open file
 +    referred to by fd. Accessing the memory beyond
 +
-+        mapped_region + 2 * sizeof(wbuf)
++        mapped_region + COUNT * sizeof(wbuf) / 2
 +
-+    causes SIGBUS to be raised.
++    should cause a signal (usually SIGBUS) to be raised.
 +  */
 +
 +  yr_initialize();
@@ -162,7 +165,7 @@ index 0000000..8ebea58
 +  */
 +
 +  int rc = yr_rules_scan_mem(
-+      rules_a, mapped_region, 4 * sizeof(wbuf), 0, count_matches, &matches, 0);
++      rules_a, mapped_region, COUNT * sizeof(wbuf), 0, count_matches, &matches, 0);
 +
 +  printf("err = %d, matches = %d\n", rc, matches);
 +
@@ -186,7 +189,7 @@ index 0000000..8ebea58
 +  */
 +
 +  rc = yr_rules_scan_mem(
-+      rules_0, mapped_region, 4 * sizeof(wbuf), 0, count_matches, &matches, 0);
++      rules_0, mapped_region, COUNT * sizeof(wbuf), 0, count_matches, &matches, 0);
 +
 +  printf("err = %d, matches = %d\n", rc, matches);
 +

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