Skip to content

Commit c37166d

Browse files
committed
Merge branch 'github_develop' into github_master
2 parents 64a995b + f815639 commit c37166d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+244
-94
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22

33
This is a list of notable changes to Hyperscan, in reverse chronological order.
44

5+
## [5.4.1] 2023-02-20
6+
- The Intel Hyperscan team is pleased to provide a bug fix release to our open source library.
7+
Intel also maintains an upgraded version available through your Intel sales representative.
8+
- Bugfix for issue #184: fix random char value of UTF-8.
9+
- Bugfix for issue #291: bypass logical combination flag in hs_expression_info().
10+
- Bugfix for issue #292: fix build error due to libc symbol parsing.
11+
- Bugfix for issue #302/304: add empty string check for pure literal API.
12+
- Bugfix for issue #303: fix unknown instruction error in pure literal API.
13+
- Bugfix for issue #303: avoid memory leak in stream close stage.
14+
- Bugfix for issue #305: fix assertion failure in DFA construction.
15+
- Bugfix for issue #317: fix aligned allocator segment faults.
16+
- Bugfix for issue #350: add quick validity check for scratch.
17+
- Bugfix for issue #359: fix glibc-2.34 stack size issue.
18+
- Bugfix for issue #360: fix SKIP flag issue in chimera.
19+
- Bugfix for issue #362: fix one cotec check corner issue in UTF-8 validation.
20+
- Fix other compile issues.
21+
522
## [5.4.0] 2020-12-31
623
- Improvement on literal matcher "Fat Teddy" performance, including
724
support for Intel(R) AVX-512 Vector Byte Manipulation Instructions (Intel(R)

CMakeLists.txt

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ project (hyperscan C CXX)
33

44
set (HS_MAJOR_VERSION 5)
55
set (HS_MINOR_VERSION 4)
6-
set (HS_PATCH_VERSION 0)
6+
set (HS_PATCH_VERSION 1)
77
set (HS_VERSION ${HS_MAJOR_VERSION}.${HS_MINOR_VERSION}.${HS_PATCH_VERSION})
88

99
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
@@ -397,6 +397,18 @@ if (CXX_UNUSED_CONST_VAR)
397397
set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -Wno-unused-const-variable")
398398
endif()
399399

400+
# clang-14 complains about unused-but-set variable.
401+
CHECK_CXX_COMPILER_FLAG("-Wunused-but-set-variable" CXX_UNUSED_BUT_SET_VAR)
402+
if (CXX_UNUSED_BUT_SET_VAR)
403+
set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -Wno-unused-but-set-variable")
404+
endif()
405+
406+
# clang-14 complains about using bitwise operator instead of logical ones.
407+
CHECK_CXX_COMPILER_FLAG("-Wbitwise-instead-of-logical" CXX_BITWISE_INSTEAD_OF_LOGICAL)
408+
if (CXX_BITWISE_INSTEAD_OF_LOGICAL)
409+
set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -Wno-bitwise-instead-of-logical")
410+
endif()
411+
400412
# gcc 6 complains about type attributes that get ignored, like alignment
401413
CHECK_CXX_COMPILER_FLAG("-Wignored-attributes" CXX_IGNORED_ATTR)
402414
if (CXX_IGNORED_ATTR)
@@ -428,8 +440,10 @@ CHECK_CXX_COMPILER_FLAG("-Wunused-variable" CXX_WUNUSED_VARIABLE)
428440

429441
# gcc 10 complains about this
430442
CHECK_C_COMPILER_FLAG("-Wstringop-overflow" CC_STRINGOP_OVERFLOW)
431-
if(CC_STRINGOP_OVERFLOW)
443+
CHECK_CXX_COMPILER_FLAG("-Wstringop-overflow" CXX_STRINGOP_OVERFLOW)
444+
if(CC_STRINGOP_OVERFLOW OR CXX_STRINGOP_OVERFLOW)
432445
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-stringop-overflow")
446+
set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -Wno-stringop-overflow")
433447
endif()
434448

435449
endif()
@@ -579,7 +593,7 @@ set (hs_exec_common_SRCS
579593

580594
set (hs_exec_SRCS
581595
${hs_HEADERS}
582-
src/hs_version.h
596+
src/hs_version.h.in
583597
src/ue2common.h
584598
src/allocator.h
585599
src/crc32.c
@@ -736,7 +750,7 @@ SET (hs_compile_SRCS
736750
src/grey.h
737751
src/hs.cpp
738752
src/hs_internal.h
739-
src/hs_version.h
753+
src/hs_version.h.in
740754
src/scratch.h
741755
src/state.h
742756
src/ue2common.h

chimera/ch_runtime.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018-2020, Intel Corporation
2+
* Copyright (c) 2018-2022, Intel Corporation
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions are met:
@@ -326,6 +326,10 @@ ch_error_t catchupPcre(struct HybridContext *hyctx, unsigned int id,
326326
} else if (cbrv == CH_CALLBACK_SKIP_PATTERN) {
327327
DEBUG_PRINTF("user callback told us to skip this pattern\n");
328328
pd->scanStart = hyctx->length;
329+
if (top_id == id) {
330+
break;
331+
}
332+
continue;
329333
}
330334

331335
if (top_id == id) {

cmake/build_wrapper.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ KEEPSYMS=$(mktemp -p /tmp keep.syms.XXXXX)
1717
LIBC_SO=$("$@" --print-file-name=libc.so.6)
1818
cp ${KEEPSYMS_IN} ${KEEPSYMS}
1919
# get all symbols from libc and turn them into patterns
20-
nm -f p -g -D ${LIBC_SO} | sed -s 's/\([^ ]*\).*/^\1$/' >> ${KEEPSYMS}
20+
nm -f p -g -D ${LIBC_SO} | sed -s 's/\([^ @]*\).*/^\1$/' >> ${KEEPSYMS}
2121
# build the object
2222
"$@"
2323
# rename the symbols in the object

examples/patbench.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015-2017, Intel Corporation
2+
* Copyright (c) 2015-2021, Intel Corporation
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions are met:
@@ -115,6 +115,7 @@
115115
#include <algorithm>
116116
#include <cstring>
117117
#include <chrono>
118+
#include <climits>
118119
#include <fstream>
119120
#include <iomanip>
120121
#include <iostream>
@@ -657,6 +658,10 @@ int main(int argc, char **argv) {
657658
break;
658659
case 'n':
659660
repeatCount = atoi(optarg);
661+
if (repeatCount <= 0 || repeatCount > UINT_MAX) {
662+
cerr << "Invalid repeatCount." << endl;
663+
exit(-1);
664+
}
660665
break;
661666
default:
662667
usage(argv[0]);

examples/pcapscan.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015-2016, Intel Corporation
2+
* Copyright (c) 2015-2021, Intel Corporation
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions are met:
@@ -51,6 +51,7 @@
5151

5252
#include <cstring>
5353
#include <chrono>
54+
#include <climits>
5455
#include <fstream>
5556
#include <iomanip>
5657
#include <iostream>
@@ -489,6 +490,10 @@ int main(int argc, char **argv) {
489490

490491
// Streaming mode scans.
491492
double secsStreamingScan = 0.0, secsStreamingOpenClose = 0.0;
493+
if (repeatCount <= 0 || repeatCount > UINT_MAX) {
494+
cerr << "Invalid repeatCount." << endl;
495+
exit(-1);
496+
}
492497
for (unsigned int i = 0; i < repeatCount; i++) {
493498
// Open streams.
494499
clock.start();

examples/simplegrep.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, Intel Corporation
2+
* Copyright (c) 2015-2021, Intel Corporation
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions are met:
@@ -57,6 +57,7 @@
5757
#include <stdio.h>
5858
#include <stdlib.h>
5959
#include <string.h>
60+
#include <unistd.h>
6061

6162
#include <hs.h>
6263

@@ -152,6 +153,15 @@ int main(int argc, char *argv[]) {
152153
char *pattern = argv[1];
153154
char *inputFN = argv[2];
154155

156+
if (access(inputFN, F_OK) != 0) {
157+
fprintf(stderr, "ERROR: file doesn't exist.\n");
158+
return -1;
159+
}
160+
if (access(inputFN, R_OK) != 0) {
161+
fprintf(stderr, "ERROR: can't be read.\n");
162+
return -1;
163+
}
164+
155165
/* First, we attempt to compile the pattern provided on the command line.
156166
* We assume 'DOTALL' semantics, meaning that the '.' meta-character will
157167
* match newline characters. The compiler will analyse the given pattern and

src/compiler/compiler.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015-2020, Intel Corporation
2+
* Copyright (c) 2015-2021, Intel Corporation
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions are met:
@@ -323,7 +323,8 @@ void addExpression(NG &ng, unsigned index, const char *expression,
323323
}
324324

325325
// Ensure that our pattern isn't too long (in characters).
326-
if (strlen(expression) > cc.grey.limitPatternLength) {
326+
size_t maxlen = cc.grey.limitPatternLength + 1;
327+
if (strnlen(expression, maxlen) >= maxlen) {
327328
throw CompileError("Pattern length exceeds limit.");
328329
}
329330

@@ -416,6 +417,10 @@ void addLitExpression(NG &ng, unsigned index, const char *expression,
416417
"HS_FLAG_SOM_LEFTMOST are supported in literal API.");
417418
}
418419

420+
if (!strcmp(expression, "")) {
421+
throw CompileError("Pure literal API doesn't support empty string.");
422+
}
423+
419424
// This expression must be a pure literal, we can build ue2_literal
420425
// directly based on expression text.
421426
ParsedLitExpression ple(index, expression, expLength, flags, id);

src/hs.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015-2020, Intel Corporation
2+
* Copyright (c) 2015-2021, Intel Corporation
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions are met:
@@ -514,6 +514,12 @@ hs_error_t hs_expression_info_int(const char *expression, unsigned int flags,
514514
return HS_COMPILER_ERROR;
515515
}
516516

517+
if (flags & HS_FLAG_COMBINATION) {
518+
*error = generateCompileError("Invalid parameter: unsupported "
519+
"logical combination expression", -1);
520+
return HS_COMPILER_ERROR;
521+
}
522+
517523
*info = nullptr;
518524
*error = nullptr;
519525

src/hs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
#define HS_MAJOR 5
4545
#define HS_MINOR 4
46-
#define HS_PATCH 0
46+
#define HS_PATCH 1
4747

4848
#include "hs_compile.h"
4949
#include "hs_runtime.h"

0 commit comments

Comments
 (0)