[Forensics-changes] [yara] 362/368: Added stdint.h fallback support. (#478)

Hilko Bengen bengen at moszumanska.debian.org
Sat Jul 1 10:30:58 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 03c2aac2c1253b096342cf4b745d66e448c7d110
Author: Joachim Metz <joachim.metz at gmail.com>
Date:   Mon Jul 18 09:39:55 2016 +0200

    Added stdint.h fallback support. (#478)
---
 .gitignore                                      |  3 ++
 libyara/grammar.y                               |  2 +-
 libyara/hash.c                                  |  2 +-
 libyara/hex_grammar.y                           |  2 +-
 libyara/include/yara/arena.h                    |  2 +-
 libyara/include/yara/elf.h                      |  4 +-
 libyara/include/yara/filemap.h                  |  2 +-
 libyara/include/yara/{sizedstr.h => integers.h} | 59 +++++++++++++------------
 libyara/include/yara/pe.h                       |  3 +-
 libyara/include/yara/sizedstr.h                 |  3 +-
 libyara/include/yara/strutils.h                 |  3 +-
 libyara/lexer.l                                 |  3 +-
 libyara/modules/pe_utils.c                      |  3 +-
 libyara/parser.c                                |  3 +-
 libyara/re_grammar.y                            |  3 +-
 15 files changed, 52 insertions(+), 45 deletions(-)

diff --git a/.gitignore b/.gitignore
index 884e451..59136e8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,6 +25,7 @@ stamp-h1
 /aclocal.m4
 /ar-lib
 /autom4te.cache/
+/compile
 /config.guess
 /config.h
 /config.h.in
@@ -38,6 +39,7 @@ stamp-h1
 /libtool
 /ltmain.sh
 /missing
+/test-driver
 /ylwrap
 /m4
 !/m4/acx_pthread.m4
@@ -45,6 +47,7 @@ stamp-h1
 # Project specific files
 /yara
 /yarac
+/libyara/modules/.dirstamp
 
 # Linux and Mac files
 *.swp
diff --git a/libyara/grammar.y b/libyara/grammar.y
index 2b867af..0090d73 100644
--- a/libyara/grammar.y
+++ b/libyara/grammar.y
@@ -32,12 +32,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include <assert.h>
 #include <stdio.h>
-#include <stdint.h>
 #include <string.h>
 #include <limits.h>
 #include <stddef.h>
 
 
+#include <yara/integers.h>
 #include <yara/utils.h>
 #include <yara/strutils.h>
 #include <yara/compiler.h>
diff --git a/libyara/hash.c b/libyara/hash.c
index 2f23e93..1ce2a53 100644
--- a/libyara/hash.c
+++ b/libyara/hash.c
@@ -27,9 +27,9 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#include <stdint.h>
 #include <string.h>
 
+#include <yara/integers.h>
 #include <yara/hash.h>
 #include <yara/mem.h>
 #include <yara/error.h>
diff --git a/libyara/hex_grammar.y b/libyara/hex_grammar.y
index af3918e..fdf7303 100644
--- a/libyara/hex_grammar.y
+++ b/libyara/hex_grammar.y
@@ -30,9 +30,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 %{
 
 #include <string.h>
-#include <stdint.h>
 #include <limits.h>
 
+#include <yara/integers.h>
 #include <yara/utils.h>
 #include <yara/hex_lexer.h>
 #include <yara/limits.h>
diff --git a/libyara/include/yara/arena.h b/libyara/include/yara/arena.h
index 745e94d..3ffe293 100644
--- a/libyara/include/yara/arena.h
+++ b/libyara/include/yara/arena.h
@@ -30,9 +30,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #ifndef YR_ARENA_H
 #define YR_ARENA_H
 
-#include <stdint.h>
 #include <stddef.h>
 
+#include <yara/integers.h>
 #include <yara/stream.h>
 
 #define ARENA_FLAGS_FIXED_SIZE   1
diff --git a/libyara/include/yara/elf.h b/libyara/include/yara/elf.h
index ed7f921..3b0ad20 100644
--- a/libyara/include/yara/elf.h
+++ b/libyara/include/yara/elf.h
@@ -30,7 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #ifndef _ELF_H
 #define _ELF_H
 
-#include <stdint.h>
+#include <yara/integers.h>
 
 
 // 32-bit ELF base types
@@ -235,4 +235,4 @@ typedef struct
 
 #pragma pack(pop)
 
-#endif
\ No newline at end of file
+#endif
diff --git a/libyara/include/yara/filemap.h b/libyara/include/yara/filemap.h
index aaa2abf..2a58076 100644
--- a/libyara/include/yara/filemap.h
+++ b/libyara/include/yara/filemap.h
@@ -44,8 +44,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #endif
 
 #include <stdlib.h>
-#include <stdint.h>
 
+#include <yara/integers.h>
 #include <yara/utils.h>
 
 
diff --git a/libyara/include/yara/sizedstr.h b/libyara/include/yara/integers.h
similarity index 62%
copy from libyara/include/yara/sizedstr.h
copy to libyara/include/yara/integers.h
index a3c72ac..25d6dfd 100644
--- a/libyara/include/yara/sizedstr.h
+++ b/libyara/include/yara/integers.h
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 2007-2014. The YARA Authors. All Rights Reserved.
+Copyright (c) 2007-2015. The YARA Authors. All Rights Reserved.
 
 Redistribution and use in source and binary forms, with or without modification,
 are permitted provided that the following conditions are met:
@@ -27,39 +27,40 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#ifndef _SIZEDSTR_H
-#define _SIZEDSTR_H
-
-#include <stddef.h>
-#include <stdint.h>
-
-//
-// This struct is used to support strings containing null chars. The length of
-// the string is stored along the string data. However the string data is also
-// terminated with a null char.
-//
-
-#define SIZED_STRING_FLAGS_NO_CASE  1
-#define SIZED_STRING_FLAGS_DOT_ALL  2
-
-#pragma pack(push)
-#pragma pack(8)
+#ifndef YR_INTEGERS_H
+#define YR_INTEGERS_H
 
+/* Integer type definitions
+ */
+#if ( defined( _MSC_VER ) && ( _MSC_VER < 1600 ) ) || ( defined( __BORLANDC__ ) && ( __BORLANDC__ <= 0x0560 ) )
 
-typedef struct _SIZED_STRING
-{
-  uint32_t length;
-  uint32_t flags;
-  
-  char c_string[1];
+#ifdef __cplusplus
+extern "C" {
+#endif
 
-} SIZED_STRING;
+/* Microsoft Visual Studio C++ before Visual Studio 2010 or earlier versions of the Borland C++ Builder
+ * do not support the (u)int#_t type definitions but have __int# defintions instead
+ */
+typedef __int8 int8_t;
+typedef unsigned __int8 uint8_t;
+typedef __int16 int16_t;
+typedef unsigned __int16 uint16_t;
+typedef __int32 int32_t;
+typedef unsigned __int32 uint32_t;
+typedef __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+
+#ifdef __cplusplus
+}
+#endif
 
-#pragma pack(pop)
+#else
 
+/* Other "compilers" and later versions of Microsoft Visual Studio C++ and
+ * Borland C/C++ define the types in <stdint.h>
+ */
+#include <stdint.h>
 
-int sized_string_cmp(
-  SIZED_STRING* s1,
-  SIZED_STRING* s2);
+#endif
 
 #endif
diff --git a/libyara/include/yara/pe.h b/libyara/include/yara/pe.h
index 8bc5362..9afa314 100644
--- a/libyara/include/yara/pe.h
+++ b/libyara/include/yara/pe.h
@@ -44,9 +44,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #else
 
-#include <stdint.h>
 #include <stdlib.h>
 
+#include <yara/integers.h>
+
 typedef uint8_t   BYTE;
 typedef uint16_t  WORD;
 typedef uint32_t  DWORD;
diff --git a/libyara/include/yara/sizedstr.h b/libyara/include/yara/sizedstr.h
index a3c72ac..9e29ec6 100644
--- a/libyara/include/yara/sizedstr.h
+++ b/libyara/include/yara/sizedstr.h
@@ -31,7 +31,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #define _SIZEDSTR_H
 
 #include <stddef.h>
-#include <stdint.h>
+
+#include <yara/integers.h>
 
 //
 // This struct is used to support strings containing null chars. The length of
diff --git a/libyara/include/yara/strutils.h b/libyara/include/yara/strutils.h
index b46da92..5f151e6 100644
--- a/libyara/include/yara/strutils.h
+++ b/libyara/include/yara/strutils.h
@@ -32,7 +32,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include <assert.h>
 #include <stdlib.h>
-#include <stdint.h>
+
+#include <yara/integers.h>
 
 #include "config.h"
 
diff --git a/libyara/lexer.l b/libyara/lexer.l
index 0119b13..640304a 100644
--- a/libyara/lexer.l
+++ b/libyara/lexer.l
@@ -47,11 +47,10 @@ with noyywrap then we can remove this pragma.
 #include <math.h>
 #include <stdarg.h>
 #include <stdio.h>
-#include <stdint.h>
 #include <string.h>
 #include <setjmp.h>
 
-
+#include <yara/integers.h>
 #include <yara/lexer.h>
 #include <yara/sizedstr.h>
 #include <yara/error.h>
diff --git a/libyara/modules/pe_utils.c b/libyara/modules/pe_utils.c
index 5cfc422..e12aebb 100644
--- a/libyara/modules/pe_utils.c
+++ b/libyara/modules/pe_utils.c
@@ -3,7 +3,8 @@
 #if !HAVE_TIMEGM
 
 #include <time.h>
-#include <stdint.h>
+
+#include <yara/integers.h>
 
 static int is_leap(
     unsigned int year)
diff --git a/libyara/parser.c b/libyara/parser.c
index 40ab507..1123869 100644
--- a/libyara/parser.c
+++ b/libyara/parser.c
@@ -422,9 +422,10 @@ int _yr_parser_write_string(
   return result;
 }
 
-#include <stdint.h>
 #include <limits.h>
 
+#include <yara/integers.h>
+
 
 YR_STRING* yr_parser_reduce_string_declaration(
     yyscan_t yyscanner,
diff --git a/libyara/re_grammar.y b/libyara/re_grammar.y
index 8a0a7d5..b69b3b6 100644
--- a/libyara/re_grammar.y
+++ b/libyara/re_grammar.y
@@ -29,8 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 %{
 
-#include <stdint.h>
-
+#include <yara/integers.h>
 #include <yara/utils.h>
 #include <yara/error.h>
 #include <yara/limits.h>

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