From: Justin Viiret Date: Mon, 6 Mar 2017 03:15:56 +0000 (+1100) Subject: ng: check can_never_match before validate_fuzzy X-Git-Tag: v4.5.0^2~195 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5edecbf539fb3b979f45c5832ef8c04c07bc085e;p=thirdparty%2Fvectorscan.git ng: check can_never_match before validate_fuzzy --- diff --git a/src/nfagraph/ng.cpp b/src/nfagraph/ng.cpp index 9453aae9..2f6d8cd7 100644 --- a/src/nfagraph/ng.cpp +++ b/src/nfagraph/ng.cpp @@ -330,6 +330,10 @@ bool NG::addGraph(NGWrapper &w) { /* ensure utf8 starts at cp boundary */ ensureCodePointStart(rm, w); + if (can_never_match(w)) { + throw CompileError(w.expressionIndex, "Pattern can never match."); + } + // validate graph's suitability for fuzzing before resolving asserts validate_fuzzy_compile(w, w.edit_distance, w.utf8, cc.grey); diff --git a/unit/hyperscan/bad_patterns.txt b/unit/hyperscan/bad_patterns.txt index 09a2f7e1..3d6d9db9 100644 --- a/unit/hyperscan/bad_patterns.txt +++ b/unit/hyperscan/bad_patterns.txt @@ -141,3 +141,4 @@ 144:/abc\b/{edit_distance=1} #Zero-width assertions are disallowed for approximate matching. 145:/abc/8{edit_distance=1} #UTF-8 is disallowed for approximate matching. 146:/(*UTF8)abc/{edit_distance=1} #UTF-8 is disallowed for approximate matching. +147:/\b\BMYBt/s{edit_distance=1} #Pattern can never match.